Skip to content

Commit 4ed2cd4

Browse files
committed
CI: made installing Winget more robust
Should fix intermittent error: Write-Error: Failed to install AppX packages: Deployment failed with HRESULT: 0x80073D02, The package could not be installed because resources it modifies are currently in use.
1 parent 4855908 commit 4ed2cd4

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,25 @@ jobs:
4343
# so we delete everything that could mess up our builds
4444
run: rmdir /S /Q C:\Strawberry
4545

46-
- name: Install Winget Dependencies from Zip (arm64)
46+
- name: Install Winget (arm64)
4747
if: contains(matrix.arch, 'arm64')
4848
run: |
49+
function Install-AppxWithRetry($path) {
50+
$maxAttempts = 5
51+
for ($attempt = 1; $attempt -le $maxAttempts; $attempt++) {
52+
try {
53+
Add-AppxPackage -Path $path -ForceApplicationShutdown -ErrorAction Stop
54+
return
55+
} catch {
56+
if ($attempt -eq $maxAttempts) {
57+
throw
58+
}
59+
Write-Warning "Add-AppxPackage failed (attempt $attempt/$maxAttempts): $($_.Exception.Message)"
60+
Start-Sleep -Seconds 5
61+
}
62+
}
63+
}
64+
4965
$tempDir = Join-Path $env:TEMP "WingetDependencies"
5066
$zipFilePath = Join-Path $env:TEMP "DesktopAppInstaller_Dependencies.zip"
5167
$archDepsDir = Join-Path $tempDir "${{ matrix.arch }}" # Path to the arm64 or x64 folder inside the unzipped content
@@ -78,20 +94,16 @@ jobs:
7894
} else {
7995
foreach ($appxFile in $appXFiles) {
8096
Write-Host "Installing $appxFile..."
81-
Add-AppxPackage -Path $appxFile
97+
Install-AppxWithRetry $appxFile
8298
}
8399
}
84100
} catch {
85101
Write-Error "Failed to install AppX packages: $($_.Exception.Message)"
86102
exit 1
87103
}
88-
shell: pwsh
89104
90-
- name: Install Winget (arm64)
91-
if: contains(matrix.arch, 'arm64')
92-
run: |
93105
Invoke-WebRequest -Uri https://github.com/microsoft/winget-cli/releases/download/v1.12.460/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle -OutFile $env:TEMP\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle
94-
Add-AppxPackage $env:TEMP\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle
106+
Install-AppxWithRetry $env:TEMP\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle
95107
shell: pwsh
96108

97109
- name: Install Dependencies

0 commit comments

Comments
 (0)