Skip to content

Commit 70b4bda

Browse files
authored
Publish .msixbundle package as a VPack (PowerShell#25612)
1 parent 5851796 commit 70b4bda

5 files changed

Lines changed: 171 additions & 6 deletions

File tree

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
trigger: none
2+
3+
parameters: # parameters are shown up in ADO UI in a build queue time
4+
- name: 'createVPack'
5+
displayName: 'Create and Submit VPack'
6+
type: boolean
7+
default: true
8+
- name: 'debug'
9+
displayName: 'Enable debug output'
10+
type: boolean
11+
default: false
12+
- name: 'ReleaseTagVar'
13+
type: string
14+
displayName: 'Release Tag Var:'
15+
default: 'fromBranch'
16+
17+
name: msixbundle_vPack_$(date:yyMM).$(date:dd)$(rev:rrr)
18+
19+
variables:
20+
CDP_DEFINITION_BUILD_COUNT: $[counter('', 0)]
21+
system.debug: ${{ parameters.debug }}
22+
BuildSolution: $(Build.SourcesDirectory)\dirs.proj
23+
ReleaseTagVar: ${{ parameters.ReleaseTagVar }}
24+
BuildConfiguration: Release
25+
WindowsContainerImage: 'onebranch.azurecr.io/windows/ltsc2019/vse2022:latest'
26+
Codeql.Enabled: false # pipeline is not building artifacts; it repackages existing artifacts into a vpack
27+
DOTNET_CLI_TELEMETRY_OPTOUT: 1
28+
POWERSHELL_TELEMETRY_OPTOUT: 1
29+
30+
resources:
31+
repositories:
32+
- repository: templates
33+
type: git
34+
name: OneBranch.Pipelines/GovernedTemplates
35+
ref: refs/heads/main
36+
37+
pipelines:
38+
- pipeline: PSPackagesOfficial
39+
source: 'PowerShell-Packages-Official'
40+
trigger:
41+
branches:
42+
include:
43+
- master
44+
- releases/*
45+
46+
extends:
47+
template: v2/Microsoft.Official.yml@templates
48+
parameters:
49+
platform:
50+
name: 'windows_undocked' # windows undocked
51+
52+
cloudvault:
53+
enabled: false
54+
55+
globalSdl:
56+
useCustomPolicy: true # for signing code
57+
disableLegacyManifest: true
58+
# disabled Armory as we dont have any ARM templates to scan. It fails on some sample ARM templates.
59+
armory:
60+
enabled: false
61+
sbom:
62+
enabled: true
63+
compiled:
64+
enabled: false
65+
credscan:
66+
enabled: true
67+
scanFolder: $(Build.SourcesDirectory)
68+
suppressionsFile: $(Build.SourcesDirectory)\.config\suppress.json
69+
binskim:
70+
enabled: false
71+
# APIScan requires a non-Ready-To-Run build
72+
apiscan:
73+
enabled: false
74+
asyncSDL:
75+
enabled: false
76+
tsaOptionsFile: .config/tsaoptions.json
77+
78+
stages:
79+
- stage: build
80+
jobs:
81+
- job: main
82+
pool:
83+
type: windows
84+
85+
variables:
86+
ob_outputDirectory: '$(BUILD.SOURCESDIRECTORY)\out'
87+
ob_createvpack_enabled: ${{ parameters.createVPack }}
88+
ob_createvpack_packagename: 'PowerShell.app'
89+
ob_createvpack_owneralias: 'dongbow'
90+
ob_createvpack_description: 'VPack for the PowerShell Application'
91+
ob_createvpack_targetDestinationDirectory: '$(Destination)'
92+
ob_createvpack_propsFile: false
93+
ob_createvpack_provData: true
94+
ob_createvpack_metadata: '$(Build.SourceVersion)'
95+
ob_createvpack_versionAs: string
96+
ob_createvpack_version: '$(version)'
97+
ob_createvpack_verbose: true
98+
99+
steps:
100+
- template: .pipelines/templates/SetVersionVariables.yml@self
101+
parameters:
102+
ReleaseTagVar: $(ReleaseTagVar)
103+
UseJson: no
104+
105+
- pwsh: |
106+
Write-Verbose -Verbose 'PowerShell Version: $(version)'
107+
if('$(version)' -match '-') {
108+
throw "Don't release a preview build msixbundle package"
109+
}
110+
displayName: Stop any preview release
111+
112+
- download: PSPackagesOfficial
113+
artifact: 'drop_msixbundle_CreateMSIXBundle'
114+
displayName: Download package
115+
116+
- pwsh: |
117+
$payloadDir = '$(Pipeline.Workspace)\PSPackagesOfficial\drop_msixbundle_CreateMSIXBundle'
118+
Get-ChildItem $payloadDir -Recurse | Out-String -Width 150
119+
$vstsCommandString = "vso[task.setvariable variable=PayloadDir]$payloadDir"
120+
Write-Host "sending " + $vstsCommandString
121+
Write-Host "##$vstsCommandString"
122+
displayName: 'Capture Artifact Listing'
123+
124+
- pwsh: |
125+
$bundlePackage = Get-ChildItem '$(PayloadDir)\*.msixbundle'
126+
Write-Verbose -Verbose ("MSIX bundle package: " + $bundlePackage.FullName -join ', ')
127+
if ($bundlePackage.Count -ne 1) {
128+
throw "Expected to find 1 MSIX bundle package, but found $($bundlePackage.Count)"
129+
}
130+
131+
if (-not (Test-Path '$(ob_outputDirectory)' -PathType Container)) {
132+
$null = New-Item '$(ob_outputDirectory)' -ItemType Directory -ErrorAction Stop
133+
}
134+
135+
$targetPath = Join-Path '$(ob_outputDirectory)' 'Microsoft.PowerShell_8wekyb3d8bbwe.msixbundle'
136+
Copy-Item -Verbose -Path $bundlePackage.FullName -Destination $targetPath
137+
displayName: 'Stage msixbundle for vpack'
138+
139+
- pwsh: |
140+
Write-Verbose "VPack Version: $(ob_createvpack_version)" -Verbose
141+
$vpackFiles = Get-ChildItem -Path $(ob_outputDirectory)\* -Recurse
142+
if($vpackFiles.Count -eq 0) {
143+
throw "No files found in $(ob_outputDirectory)"
144+
}
145+
$vpackFiles | Out-String -Width 150
146+
displayName: Debug Output Directory and Version
147+
condition: succeededOrFailed()

.pipelines/PowerShell-Release-Official.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,11 @@ extends:
368368
jobs:
369369
- template: /.pipelines/templates/approvalJob.yml@self
370370
parameters:
371-
displayName: Start vPack Release pipeline
371+
displayName: Start 2 vPack Release pipelines
372372
jobName: PublishVPack
373373
instructions: |
374-
Kick off vPack release pipeline
374+
1. Kick off PowerShell-vPack-Official pipeline
375+
2. Kick off PowerShell-MSIXBundle-VPack pipeline
375376
376377
# Need to verify if the Az PS / CLI team still uses this. Skippinng for this release.
377378
# - stage: ReleaseDeps

.pipelines/templates/SetVersionVariables.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ steps:
2323
}
2424
if(Test-Path -Path $path)
2525
{
26-
Write-Verbose "reporoot detect at: ." -Verbose
26+
Write-Verbose "reporoot detected at: ." -Verbose
2727
$repoRoot = '.'
2828
}
2929
else{
@@ -51,7 +51,7 @@ steps:
5151
$REPOROOT = $env:REPOROOT
5252
5353
if (-not (Test-Path $REPOROOT/tools/releaseBuild/setReleaseTag.ps1)) {
54-
if ((Test-Path "$REPOROOT/PowerShell/tools/releaseBuild/setReleaseTag.ps1")) {
54+
if (Test-Path "$REPOROOT/PowerShell/tools/releaseBuild/setReleaseTag.ps1") {
5555
$REPOROOT = "$REPOROOT/PowerShell"
5656
} else {
5757
throw "Could not find setReleaseTag.ps1 in $REPOROOT/tools/releaseBuild or $REPOROOT/PowerShell/tools/releaseBuild"
@@ -72,7 +72,7 @@ steps:
7272
ob_restore_phase: true # This ensures this done in restore phase to workaround signing issue
7373

7474
- powershell: |
75-
Get-ChildItem -Path env: | Out-String -width 9999 -Stream | write-Verbose -Verbose
75+
Get-ChildItem -Path Env: | Out-String -Width 150
7676
displayName: Capture environment
7777
condition: succeededOrFailed()
7878
env:

assets/AppxManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,5 @@
4848
<rescap:Capability Name="packageManagement" />
4949
<rescap:Capability Name="packageQuery" />
5050
</Capabilities>
51+
<mp:PhoneIdentity PhoneProductId="$PHONEPRODUCTID$" PhonePublisherId="95d94207-0c7c-47ed-82db-d75c81153c35" />
5152
</Package>

tools/packaging/packaging.psm1

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3707,8 +3707,17 @@ function New-MSIXPackage
37073707

37083708
$ProductVersion = Get-WindowsVersion -PackageName $packageName
37093709

3710+
# Any app that is submitted to the Store must have a PhoneIdentity in its appxmanifest.
3711+
# If you submit a package without this information to the Store, the Store will silently modify your package to include it.
3712+
# To find the PhoneProductId value, you need to run a package through the Store certification process,
3713+
# and use the PhoneProductId value from the Store certified package to update the manifest in your source code.
3714+
# This is the PhoneProductId for the "Microsoft.PowerShell" package.
3715+
$PhoneProductId = "5b3ae196-2df7-446e-8060-94b4ad878387"
3716+
37103717
$isPreview = Test-IsPreview -Version $ProductSemanticVersion
37113718
if ($isPreview) {
3719+
# This is the PhoneProductId for the "Microsoft.PowerShellPreview" package.
3720+
$PhoneProductId = "67859fd2-b02a-45be-8fb5-62c569a3e8bf"
37123721
Write-Verbose "Using Preview assets" -Verbose
37133722
}
37143723

@@ -3718,7 +3727,14 @@ function New-MSIXPackage
37183727
$releasePublisher = 'CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US'
37193728

37203729
$appxManifest = Get-Content "$RepoRoot\assets\AppxManifest.xml" -Raw
3721-
$appxManifest = $appxManifest.Replace('$VERSION$', $ProductVersion).Replace('$ARCH$', $Architecture).Replace('$PRODUCTNAME$', $productName).Replace('$DISPLAYNAME$', $displayName).Replace('$PUBLISHER$', $releasePublisher)
3730+
$appxManifest = $appxManifest.
3731+
Replace('$VERSION$', $ProductVersion).
3732+
Replace('$ARCH$', $Architecture).
3733+
Replace('$PRODUCTNAME$', $productName).
3734+
Replace('$DISPLAYNAME$', $displayName).
3735+
Replace('$PUBLISHER$', $releasePublisher).
3736+
Replace('$PHONEPRODUCTID$', $PhoneProductId)
3737+
37223738
$xml = [xml]$appxManifest
37233739
if ($isPreview) {
37243740
Write-Verbose -Verbose "Adding pwsh-preview.exe alias"

0 commit comments

Comments
 (0)