From 9d36e139bce8a955b3b3ae18f3bee2bc1a6de982 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Thu, 4 May 2023 09:51:16 -0700 Subject: [PATCH] For Preview releases, add `pwsh-preview.exe` alias to MSIX package (#19602) * For Preview releases, add `pwsh-preview.exe` alias to MSIX package * add ability to produce private msix pkg for testing --- tools/packaging/packaging.psm1 | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/tools/packaging/packaging.psm1 b/tools/packaging/packaging.psm1 index ce4d3a95fb..f0d5cf5290 100644 --- a/tools/packaging/packaging.psm1 +++ b/tools/packaging/packaging.psm1 @@ -61,6 +61,8 @@ function Start-PSPackage { [ValidateScript({$Environment.IsMacOS})] [string] $MacOSRuntime, + [switch] $Private, + [Switch] $Force, [Switch] $SkipReleaseChecks, @@ -473,6 +475,7 @@ function Start-PSPackage { ProductVersion = $Version Architecture = $WindowsRuntime.Split('-')[1] Force = $Force + Private = $Private } if ($PSCmdlet.ShouldProcess("Create MSIX Package")) { @@ -3602,6 +3605,9 @@ function New-MSIXPackage [ValidateSet('x64','x86','arm','arm64')] [string] $Architecture, + # Produce private package for testing in Store + [Switch] $Private, + # Force overwrite of package [Switch] $Force, @@ -3630,13 +3636,20 @@ function New-MSIXPackage $ProductSemanticVersion = Get-PackageSemanticVersion -Version $ProductVersion $productSemanticVersionWithName = $ProductName + '-' + $ProductSemanticVersion $packageName = $productSemanticVersionWithName + if ($Private) { + $ProductNameSuffix = 'Private' + } + if ($ProductNameSuffix) { $packageName += "-$ProductNameSuffix" } $displayName = $productName - if ($ProductSemanticVersion.Contains('-')) { + if ($Private) { + $ProductName = 'PowerShell-Private' + $displayName = 'PowerShell-Private' + } elseif ($ProductSemanticVersion.Contains('-')) { $ProductName += 'Preview' $displayName += ' Preview' } @@ -3658,7 +3671,15 @@ function New-MSIXPackage $appxManifest = Get-Content "$RepoRoot\assets\AppxManifest.xml" -Raw $appxManifest = $appxManifest.Replace('$VERSION$', $ProductVersion).Replace('$ARCH$', $Architecture).Replace('$PRODUCTNAME$', $productName).Replace('$DISPLAYNAME$', $displayName).Replace('$PUBLISHER$', $releasePublisher) - Set-Content -Path "$ProductSourcePath\AppxManifest.xml" -Value $appxManifest -Force + $xml = [xml]$appxManifest + if ($isPreview) { + Write-Verbose -Verbose "Adding pwsh-preview.exe alias" + $aliasNode = $xml.Package.Applications.Application.Extensions.Extension.AppExecutionAlias.ExecutionAlias.Clone() + $aliasNode.alias = "pwsh-preview.exe" + $xml.Package.Applications.Application.Extensions.Extension.AppExecutionAlias.AppendChild($aliasNode) | Out-Null + } + $xml.Save("$ProductSourcePath\AppxManifest.xml") + # Necessary image assets need to be in source assets folder $assets = @( 'Square150x150Logo'