From 229f5172540726ada4c05a668f6bd06a48704bc9 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Tue, 27 May 2025 09:59:37 -0700 Subject: [PATCH 1/8] Add VPack pipeline for msixbundle package --- .pipelines/MSIXBundle-vPack-Official.yml | 134 +++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 .pipelines/MSIXBundle-vPack-Official.yml diff --git a/.pipelines/MSIXBundle-vPack-Official.yml b/.pipelines/MSIXBundle-vPack-Official.yml new file mode 100644 index 00000000000..b8ce3f4618c --- /dev/null +++ b/.pipelines/MSIXBundle-vPack-Official.yml @@ -0,0 +1,134 @@ +trigger: none + +parameters: # parameters are shown up in ADO UI in a build queue time +- name: 'createVPack' + displayName: 'Create and Submit VPack' + type: boolean + default: true +- name: 'debug' + displayName: 'Enable debug output' + type: boolean + default: false +- name: 'ReleaseTagVar' + type: string + displayName: 'Release Tag Var:' + default: 'fromBranch' + +name: msixbundle_vPack_$(date:yyMM).$(date:dd)$(rev:rrr) + +variables: + CDP_DEFINITION_BUILD_COUNT: $[counter('', 0)] + system.debug: ${{ parameters.debug }} + BuildSolution: $(Build.SourcesDirectory)\dirs.proj + ReleaseTagVar: ${{ parameters.ReleaseTagVar }} + BuildConfiguration: Release + WindowsContainerImage: 'onebranch.azurecr.io/windows/ltsc2019/vse2022:latest' + Codeql.Enabled: false # pipeline is not building artifacts; it repackages existing artifacts into a vpack + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + POWERSHELL_TELEMETRY_OPTOUT: 1 + +resources: + repositories: + - repository: templates + type: git + name: OneBranch.Pipelines/GovernedTemplates + ref: refs/heads/main + + pipelines: + - pipeline: PSPackagesOfficial + source: 'PowerShell-Packages-Official' + trigger: + branches: + include: + - master + - releases/* + +extends: + template: v2/Microsoft.Official.yml@templates + parameters: + platform: + name: 'windows_undocked' # windows undocked + + cloudvault: + enabled: false + + globalSdl: + useCustomPolicy: true # for signing code + disableLegacyManifest: true + # disabled Armory as we dont have any ARM templates to scan. It fails on some sample ARM templates. + armory: + enabled: false + sbom: + enabled: true + compiled: + enabled: false + credscan: + enabled: true + scanFolder: $(Build.SourcesDirectory) + suppressionsFile: $(Build.SourcesDirectory)\.config\suppress.json + binskim: + enabled: false + # APIScan requires a non-Ready-To-Run build + apiscan: + enabled: false + asyncSDL: + enabled: false + tsaOptionsFile: .config/tsaoptions.json + + stages: + - stage: build + jobs: + - job: main + pool: + type: windows + + variables: + ob_outputDirectory: '$(BUILD.SOURCESDIRECTORY)\out' + ob_createvpack_enabled: ${{ parameters.createVPack }} + ob_createvpack_packagename: 'PowerShell.app' + ob_createvpack_owneralias: 'dongbow' + ob_createvpack_description: 'VPack for the PowerShell Application' + ob_createvpack_targetDestinationDirectory: '$(Destination)' + ob_createvpack_propsFile: false + ob_createvpack_provData: true + ob_createvpack_versionAs: string + ob_createvpack_version: '$(version)' + ob_createvpack_verbose: true + + steps: + - template: .pipelines/templates/SetVersionVariables.yml@self + parameters: + ReleaseTagVar: $(ReleaseTagVar) + CreateJson: yes + UseJson: no + + - pwsh: | + Write-Verbose -Verbose 'PowerShell Version: $(version)' + if('$(version)' -match '-') { + throw "Don't release a preview build msixbundle package" + } + displayName: Stop any preview release + + - download: PSPackagesOfficial + artifact: 'drop_msixbundle_CreateMSIXBundle' + displayName: Download package + + - pwsh: | + Get-ChildItem '$(Pipeline.Workspace)\PSPackagesOfficial' -Recurse | Out-String -Width 150 + displayName: 'Capture Artifact Listing' + + - pwsh: | + $bundlePackage = Get-ChildItem '$(Pipeline.Workspace)\PSPackagesOfficial\*.msixbundle' + $targetPath = Join-Path '$(ob_outputDirectory)' 'Microsoft.PowerShell_8wekyb3d8bbwe.msixbundle' + Copy-Item -Verbose -Path $bundlePackage.FullName -Destination $targetPath + displayName: 'Stage msixbundle for vpack' + + - pwsh: | + Write-Verbose "VPack Version: $(ob_createvpack_version)" -Verbose + $vpackFiles = Get-ChildItem -Path $(ob_outputDirectory)\* -Recurse + if($vpackFiles.Count -eq 0) { + throw "No files found in $(ob_outputDirectory)" + } + $vpackFiles | Out-String -Width 150 + displayName: Debug Output Directory and Version + condition: succeededOrFailed() From dd789a963818d126ff92b6801bfa64680f272a0a Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Tue, 27 May 2025 11:07:36 -0700 Subject: [PATCH 2/8] Minor changes --- .pipelines/templates/SetVersionVariables.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pipelines/templates/SetVersionVariables.yml b/.pipelines/templates/SetVersionVariables.yml index 5f2c098b682..9f692373f6c 100644 --- a/.pipelines/templates/SetVersionVariables.yml +++ b/.pipelines/templates/SetVersionVariables.yml @@ -23,7 +23,7 @@ steps: } if(Test-Path -Path $path) { - Write-Verbose "reporoot detect at: ." -Verbose + Write-Verbose "reporoot detected at: ." -Verbose $repoRoot = '.' } else{ @@ -51,7 +51,7 @@ steps: $REPOROOT = $env:REPOROOT if (-not (Test-Path $REPOROOT/tools/releaseBuild/setReleaseTag.ps1)) { - if ((Test-Path "$REPOROOT/PowerShell/tools/releaseBuild/setReleaseTag.ps1")) { + if (Test-Path "$REPOROOT/PowerShell/tools/releaseBuild/setReleaseTag.ps1") { $REPOROOT = "$REPOROOT/PowerShell" } else { throw "Could not find setReleaseTag.ps1 in $REPOROOT/tools/releaseBuild or $REPOROOT/PowerShell/tools/releaseBuild" @@ -72,7 +72,7 @@ steps: ob_restore_phase: true # This ensures this done in restore phase to workaround signing issue - powershell: | - Get-ChildItem -Path env: | Out-String -width 9999 -Stream | write-Verbose -Verbose + Get-ChildItem -Path Env: | Out-String -Width 150 displayName: Capture environment condition: succeededOrFailed() env: From 62d42714727b4544408fe40ccfb8bbbca3b31cd3 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Tue, 27 May 2025 11:41:12 -0700 Subject: [PATCH 3/8] Fix the copy of msixbundle package --- .pipelines/MSIXBundle-vPack-Official.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.pipelines/MSIXBundle-vPack-Official.yml b/.pipelines/MSIXBundle-vPack-Official.yml index b8ce3f4618c..8c41db137ae 100644 --- a/.pipelines/MSIXBundle-vPack-Official.yml +++ b/.pipelines/MSIXBundle-vPack-Official.yml @@ -114,11 +114,24 @@ extends: displayName: Download package - pwsh: | - Get-ChildItem '$(Pipeline.Workspace)\PSPackagesOfficial' -Recurse | Out-String -Width 150 + $payloadDir = '$(Pipeline.Workspace)\PSPackagesOfficial\drop_msixbundle_CreateMSIXBundle' + Get-ChildItem $payloadDir -Recurse | Out-String -Width 150 + $vstsCommandString = "vso[task.setvariable variable=PayloadDir]$payloadDir" + Write-Host "sending " + $vstsCommandString + Write-Host "##$vstsCommandString" displayName: 'Capture Artifact Listing' - pwsh: | - $bundlePackage = Get-ChildItem '$(Pipeline.Workspace)\PSPackagesOfficial\*.msixbundle' + $bundlePackage = Get-ChildItem '$(PayloadDir)\*.msixbundle' + Write-Verbose -Verbose ("MSIX bundle package: " + $bundlePackage.FullName -join ', ') + if ($bundlePackage.Count -ne 1) { + throw "Expected to find 1 MSIX bundle package, but found $($bundlePackage.Count)" + } + + if (-not (Test-Path '$(ob_outputDirectory)' -PathType Container)) { + $null = New-Item '$(ob_outputDirectory)' -ItemType Directory -ErrorAction Stop + } + $targetPath = Join-Path '$(ob_outputDirectory)' 'Microsoft.PowerShell_8wekyb3d8bbwe.msixbundle' Copy-Item -Verbose -Path $bundlePackage.FullName -Destination $targetPath displayName: 'Stage msixbundle for vpack' From b47009e592ad4025a619b46031db3ebbeaabf01e Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Tue, 27 May 2025 12:17:23 -0700 Subject: [PATCH 4/8] Skip creating the 'stable.json' file --- .pipelines/MSIXBundle-vPack-Official.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.pipelines/MSIXBundle-vPack-Official.yml b/.pipelines/MSIXBundle-vPack-Official.yml index 8c41db137ae..637567c6518 100644 --- a/.pipelines/MSIXBundle-vPack-Official.yml +++ b/.pipelines/MSIXBundle-vPack-Official.yml @@ -99,7 +99,6 @@ extends: - template: .pipelines/templates/SetVersionVariables.yml@self parameters: ReleaseTagVar: $(ReleaseTagVar) - CreateJson: yes UseJson: no - pwsh: | From 19f92972689e130d78205772e0c30a9068e1c01d Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Wed, 28 May 2025 10:19:22 -0700 Subject: [PATCH 5/8] Add 'ob_createvpack_metadata' --- .pipelines/MSIXBundle-vPack-Official.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pipelines/MSIXBundle-vPack-Official.yml b/.pipelines/MSIXBundle-vPack-Official.yml index 637567c6518..f20e8a31114 100644 --- a/.pipelines/MSIXBundle-vPack-Official.yml +++ b/.pipelines/MSIXBundle-vPack-Official.yml @@ -91,6 +91,7 @@ extends: ob_createvpack_targetDestinationDirectory: '$(Destination)' ob_createvpack_propsFile: false ob_createvpack_provData: true + ob_createvpack_metadata: '$(Build.SourceVersion)' ob_createvpack_versionAs: string ob_createvpack_version: '$(version)' ob_createvpack_verbose: true From 515a453f6528cf670465529c2b7061ab846595c8 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Wed, 28 May 2025 15:31:46 -0700 Subject: [PATCH 6/8] Add 'PhoneIdentity' to the AppxManifest.xml file --- assets/AppxManifest.xml | 1 + tools/packaging/packaging.psm1 | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/assets/AppxManifest.xml b/assets/AppxManifest.xml index c646bcdf94b..50a8c7af45d 100644 --- a/assets/AppxManifest.xml +++ b/assets/AppxManifest.xml @@ -48,4 +48,5 @@ + diff --git a/tools/packaging/packaging.psm1 b/tools/packaging/packaging.psm1 index 4b54a2ff1c2..ad8f2e5286b 100644 --- a/tools/packaging/packaging.psm1 +++ b/tools/packaging/packaging.psm1 @@ -3707,8 +3707,17 @@ function New-MSIXPackage $ProductVersion = Get-WindowsVersion -PackageName $packageName + # Any app that is submitted to the Store must have a PhoneIdentity in its appxmanifest. + # If you submit a package without this information to the Store, the Store will silently modify your package to include it. + # To find the PhoneProductId value, you need to run a package through the Store certification process, + # and use the PhoneProductId value from the Store certified package to update the manifest in your source code. + # This is the PhoneProductId for the "Microsoft.PowerShell" package. + $PhoneProductId = "5b3ae196-2df7-446e-8060-94b4ad878387" + $isPreview = Test-IsPreview -Version $ProductSemanticVersion if ($isPreview) { + # This is the PhoneProductId for the "Microsoft.PowerShellPreview" package. + $PhoneProductId = "67859fd2-b02a-45be-8fb5-62c569a3e8bf" Write-Verbose "Using Preview assets" -Verbose } @@ -3718,7 +3727,14 @@ function New-MSIXPackage $releasePublisher = 'CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US' $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) + $appxManifest = $appxManifest + .Replace('$VERSION$', $ProductVersion) + .Replace('$ARCH$', $Architecture) + .Replace('$PRODUCTNAME$', $productName) + .Replace('$DISPLAYNAME$', $displayName) + .Replace('$PUBLISHER$', $releasePublisher) + .Replace('$PHONEPRODUCTID$', $PhoneProductId) + $xml = [xml]$appxManifest if ($isPreview) { Write-Verbose -Verbose "Adding pwsh-preview.exe alias" From e3e151e01443633fdb43a5a466dbc3493e24dc1c Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Wed, 28 May 2025 15:43:26 -0700 Subject: [PATCH 7/8] Update release pipeline to include the msixbundle vpack pipeline --- .pipelines/PowerShell-Release-Official.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.pipelines/PowerShell-Release-Official.yml b/.pipelines/PowerShell-Release-Official.yml index 59e1b6cd88b..0c41442da9f 100644 --- a/.pipelines/PowerShell-Release-Official.yml +++ b/.pipelines/PowerShell-Release-Official.yml @@ -368,10 +368,11 @@ extends: jobs: - template: /.pipelines/templates/approvalJob.yml@self parameters: - displayName: Start vPack Release pipeline + displayName: Start 2 vPack Release pipelines jobName: PublishVPack instructions: | - Kick off vPack release pipeline + 1. Kick off PowerShell-vPack-Official pipeline + 2. Kick off PowerShell-MSIXBundle-VPack pipeline # Need to verify if the Az PS / CLI team still uses this. Skippinng for this release. # - stage: ReleaseDeps From 60ee87c03b719e4d0eb8062621687ae60f2dbcaf Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Thu, 29 May 2025 11:20:29 -0700 Subject: [PATCH 8/8] Fix script --- tools/packaging/packaging.psm1 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/packaging/packaging.psm1 b/tools/packaging/packaging.psm1 index ad8f2e5286b..52355c1eb4f 100644 --- a/tools/packaging/packaging.psm1 +++ b/tools/packaging/packaging.psm1 @@ -3727,13 +3727,13 @@ function New-MSIXPackage $releasePublisher = 'CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US' $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) - .Replace('$PHONEPRODUCTID$', $PhoneProductId) + $appxManifest = $appxManifest. + Replace('$VERSION$', $ProductVersion). + Replace('$ARCH$', $Architecture). + Replace('$PRODUCTNAME$', $productName). + Replace('$DISPLAYNAME$', $displayName). + Replace('$PUBLISHER$', $releasePublisher). + Replace('$PHONEPRODUCTID$', $PhoneProductId) $xml = [xml]$appxManifest if ($isPreview) {