Skip to content

Commit 0b3c312

Browse files
committed
ci(release): Optimize the MSIX packaging process to avoid modifying the original manifest file
- Add Package.build.appxmanifest as a temporary manifest copy during the build process - Modify the CI script to use the build manifest instead of directly editing the original Package.appxmanifest Adjust project configuration to allow specifying the build manifest via the AppxManifestFile parameter - Improve the MSIX package search logic to adapt to the new packaging output path
1 parent 0f5e9ca commit 0b3c312

3 files changed

Lines changed: 65 additions & 24 deletions

File tree

.github/workflows/release.yml

Lines changed: 58 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -194,22 +194,26 @@ jobs:
194194
- name: Restore
195195
run: dotnet restore DevTools.csproj
196196

197-
- name: Update Package.appxmanifest
197+
- name: Prepare Package.appxmanifest build copy
198198
shell: pwsh
199199
env:
200200
VERSION: ${{ needs.extract-version.outputs.version }}
201201
PACKAGE_NAME: ${{ env.PACKAGE_NAME }}
202202
DISPLAY_NAME: ${{ env.DISPLAY_NAME }}
203203
PUBLISHER_ID: ${{ env.PUBLISHER_ID }}
204204
run: |
205-
$manifestPath = "DevTools.Package\Package.appxmanifest"
206-
$manifestContent = Get-Content $manifestPath -Raw
205+
# Copy the original manifest to a build copy and replace placeholders there.
206+
# The original Package.appxmanifest is never modified.
207+
$srcPath = "DevTools.Package\Package.appxmanifest"
208+
$buildPath = "DevTools.Package\Package.build.appxmanifest"
209+
Copy-Item $srcPath $buildPath -Force
210+
$manifestContent = [System.IO.File]::ReadAllText($buildPath)
207211
$manifestContent = $manifestContent -replace '\$PACKAGE_NAME\$', "${{ env.PACKAGE_NAME }}"
208212
$manifestContent = $manifestContent -replace '\$PUBLISHER_ID\$', "${{ env.PUBLISHER_ID }}"
209213
$manifestContent = $manifestContent -replace '\$DISPLAY_NAME\$', "${{ env.DISPLAY_NAME }}"
210214
$manifestContent = $manifestContent -replace 'Version="\$VERSION\$"', "Version=`"${{ env.VERSION }}.0`""
211215
$manifestContent = $manifestContent -replace '\$ARCHITECTURE\$', "x64"
212-
Set-Content $manifestPath -Value $manifestContent -Encoding UTF8
216+
[System.IO.File]::WriteAllText($buildPath, $manifestContent)
213217
214218
- name: Setup MSBuild
215219
uses: microsoft/setup-msbuild@v2
@@ -254,20 +258,29 @@ jobs:
254258
255259
- name: Build MSIX x64
256260
run: |
257-
(Get-Content "DevTools.Package\Package.appxmanifest") -replace 'ProcessorArchitecture="[^"]*"' , 'ProcessorArchitecture="x64"' | Set-Content "DevTools.Package\Package.appxmanifest"
258-
msbuild DevTools.Package\DevTools.Package.wapproj /p:Configuration=Release /p:Platform=x64 /p:AppxPackageDir=AppPackages\x64\ /t:Build /p:RestorePackages=true
261+
$buildPath = "DevTools.Package\Package.build.appxmanifest"
262+
$content = [System.IO.File]::ReadAllText($buildPath)
263+
$content = $content -replace 'ProcessorArchitecture="[^"]*"', 'ProcessorArchitecture="x64"'
264+
[System.IO.File]::WriteAllText($buildPath, $content)
265+
msbuild DevTools.Package\DevTools.Package.wapproj /p:Configuration=Release /p:Platform=x64 /t:Build /p:RestorePackages=true /p:AppxManifestFile=Package.build.appxmanifest
259266
shell: pwsh
260267

261268
- name: Build MSIX x86
262269
run: |
263-
(Get-Content "DevTools.Package\Package.appxmanifest") -replace 'ProcessorArchitecture="[^"]*"' , 'ProcessorArchitecture="x86"' | Set-Content "DevTools.Package\Package.appxmanifest"
264-
msbuild DevTools.Package\DevTools.Package.wapproj /p:Configuration=Release /p:Platform=x86 /p:AppxPackageDir=AppPackages\x86\ /t:Build /p:RestorePackages=true
270+
$buildPath = "DevTools.Package\Package.build.appxmanifest"
271+
$content = [System.IO.File]::ReadAllText($buildPath)
272+
$content = $content -replace 'ProcessorArchitecture="[^"]*"', 'ProcessorArchitecture="x86"'
273+
[System.IO.File]::WriteAllText($buildPath, $content)
274+
msbuild DevTools.Package\DevTools.Package.wapproj /p:Configuration=Release /p:Platform=x86 /t:Build /p:RestorePackages=true /p:AppxManifestFile=Package.build.appxmanifest
265275
shell: pwsh
266276

267277
- name: Build MSIX arm64
268278
run: |
269-
(Get-Content "DevTools.Package\Package.appxmanifest") -replace 'ProcessorArchitecture="[^"]*"' , 'ProcessorArchitecture="arm64"' | Set-Content "DevTools.Package\Package.appxmanifest"
270-
msbuild DevTools.Package\DevTools.Package.wapproj /p:Configuration=Release /p:Platform=arm64 /p:AppxPackageDir=AppPackages\arm64\ /t:Build /p:RestorePackages=true
279+
$buildPath = "DevTools.Package\Package.build.appxmanifest"
280+
$content = [System.IO.File]::ReadAllText($buildPath)
281+
$content = $content -replace 'ProcessorArchitecture="[^"]*"', 'ProcessorArchitecture="arm64"'
282+
[System.IO.File]::WriteAllText($buildPath, $content)
283+
msbuild DevTools.Package\DevTools.Package.wapproj /p:Configuration=Release /p:Platform=arm64 /t:Build /p:RestorePackages=true /p:AppxManifestFile=Package.build.appxmanifest
271284
shell: pwsh
272285

273286
- name: Create MSIX bundle
@@ -276,31 +289,50 @@ jobs:
276289
$version = "${{ needs.extract-version.outputs.version }}"
277290
$makeappx = Get-ChildItem -Path "${env:ProgramFiles(x86)}\Windows Kits\10\bin\*\x64\makeappx.exe" | Sort-Object { $_.VersionInfo.FileVersion } -Descending | Select-Object -First 1
278291
279-
$msixFiles = @(
280-
"AppPackages\x64\DevTools.Package_${version}.0_x64.msix",
281-
"AppPackages\x86\DevTools.Package_${version}.0_x86.msix",
282-
"AppPackages\arm64\DevTools.Package_${version}.0_arm64.msix"
283-
)
292+
# MSIX files are generated in *_Test subdirectories under AppPackages
293+
# Search both possible locations: repo root and DevTools.Package
294+
$searchPaths = @("AppPackages", "DevTools.Package\AppPackages")
295+
$allMsixFiles = @()
296+
foreach ($searchPath in $searchPaths) {
297+
if (Test-Path $searchPath) {
298+
$files = Get-ChildItem -Path $searchPath -Recurse -Filter "*.msix" -ErrorAction SilentlyContinue |
299+
Where-Object { $_.Name -notmatch "_Debug\.msix$" }
300+
$allMsixFiles += $files
301+
}
302+
}
284303
304+
# Select one MSIX file per architecture (x64, x86, arm64)
285305
$existingFiles = @()
286-
foreach ($f in $msixFiles) {
287-
if (Test-Path $f) {
288-
$existingFiles += $f
289-
Write-Host "Found: $f"
306+
foreach ($arch in @("x64", "x86", "arm64")) {
307+
$archFile = $allMsixFiles | Where-Object { $_.Name -match "_${arch}\.msix$" } | Select-Object -First 1
308+
if ($archFile) {
309+
$existingFiles += $archFile.FullName
310+
Write-Host "Found ${arch}: $($archFile.FullName)"
290311
} else {
291-
Write-Host "Missing: $f"
312+
Write-Host "Missing ${arch} MSIX file"
292313
}
293314
}
294315
295316
if ($existingFiles.Count -eq 0) {
296317
Write-Host "No MSIX files found, listing all files..."
297-
Get-ChildItem AppPackages -Recurse -ErrorAction SilentlyContinue | ForEach-Object { Write-Host $_.FullName }
318+
foreach ($searchPath in $searchPaths) {
319+
if (Test-Path $searchPath) {
320+
Get-ChildItem $searchPath -Recurse | ForEach-Object { Write-Host $_.FullName }
321+
}
322+
}
298323
exit 1
299324
}
300325
301326
$bundlePath = "DevTools_${version}_bundle.msixbundle"
302327
$inputFile = "bundle_input.txt"
303-
$existingFiles | Set-Content $inputFile
328+
# makeappx bundle expects a mapping file with [Files] header and
329+
# quoted "source" "destination" pairs (one per line).
330+
$lines = @("[Files]")
331+
foreach ($f in $existingFiles) {
332+
$fileName = Split-Path $f -Leaf
333+
$lines += "`"$f`" `"$fileName`""
334+
}
335+
[System.IO.File]::WriteAllLines($inputFile, $lines)
304336
305337
Write-Host "Creating bundle: $bundlePath"
306338
& $makeappx.FullName bundle /f $inputFile /p $bundlePath /o
@@ -313,9 +345,12 @@ jobs:
313345
- name: Show output
314346
shell: pwsh
315347
run: |
316-
Write-Host "=== AppPackages ==="
348+
Write-Host "=== AppPackages (repo root) ==="
317349
Get-ChildItem AppPackages -Recurse -ErrorAction SilentlyContinue
318350
351+
Write-Host "=== AppPackages (DevTools.Package) ==="
352+
Get-ChildItem DevTools.Package\AppPackages -Recurse -ErrorAction SilentlyContinue
353+
319354
Write-Host "=== All MSIX files ==="
320355
Get-ChildItem . -Recurse -Filter *.msix -ErrorAction SilentlyContinue | Select-Object FullName
321356

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ node_modules/
142142
**/Add-AppDevPackage.resources/
143143
**/TelemetryDependencies/
144144

145+
# MSIX build-only manifest copy (generated from Package.appxmanifest)
146+
Package.build.appxmanifest
147+
145148
# If .vs was already committed, remove it from the repo with:
146149
# git rm -r --cached .vs && git commit -m "Remove .vs from repo"
147150

DevTools.Package/DevTools.Package.wapproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,11 @@
7272
<AppxPackageSigningTimestampServerUrl>http://timestamp.digicert.com</AppxPackageSigningTimestampServerUrl>
7373
<AppxHashAlgorithm>SHA256</AppxHashAlgorithm>
7474
</PropertyGroup>
75+
<PropertyGroup>
76+
<AppxManifestFile Condition="'$(AppxManifestFile)' == ''">Package.appxmanifest</AppxManifestFile>
77+
</PropertyGroup>
7578
<ItemGroup>
76-
<AppxManifest Include="Package.appxmanifest">
79+
<AppxManifest Include="$(AppxManifestFile)">
7780
<SubType>Designer</SubType>
7881
</AppxManifest>
7982
</ItemGroup>

0 commit comments

Comments
 (0)