Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/windows-dev-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,8 @@ The setup targets the public stable release pinned in [`steps/_winget.ps1`](step

The step is best-effort, so a machine that can't be updated is flagged rather than stopped, and the rest of the run continues on whatever winget it has.

Setup reuses installed dependencies that meet the required version for the same package name, publisher, and architecture.

An installed version equal to or newer than the pin skips the update without a network lookup. RPC recovery re-registers the installed App Installer package locally, then retries the package query; it does not download or downgrade a newer version.

To change the target release, update `DevConfigWinGetTargetVersion` and both asset hashes in `steps/_winget.ps1` together, then sign and publish the payload as usual.
Expand Down
30 changes: 27 additions & 3 deletions src/windows-dev-config/steps/_winget.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,31 @@ function Invoke-DevConfigWinGetDeployment {
}
)
$bundle = Join-Path $Directory 'Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle'
Add-AppxPackage -Path $bundle -DependencyPath $dependencies -ForceTargetApplicationShutdown -ErrorAction Stop
Add-Type -AssemblyName System.IO.Compression.FileSystem
$dependencies = @(
foreach ($dependency in $dependencies) {
$archive = [IO.Compression.ZipFile]::OpenRead($dependency)
try {
$entry = $archive.GetEntry('AppxManifest.xml')
if (-not $entry) { throw "Missing AppxManifest.xml in $dependency." }
$reader = [IO.StreamReader]::new($entry.Open())
try { $manifest = [xml]$reader.ReadToEnd() } finally { $reader.Dispose() }
} finally { $archive.Dispose() }
$identity = $manifest.Package.Identity
if (-not $identity.Name -or -not $identity.Publisher -or -not $identity.ProcessorArchitecture -or -not $identity.Version) {
throw "Incomplete dependency identity in $dependency."
}
$installed = @(Get-AppxPackage -Name $identity.Name -ErrorAction Stop | Where-Object {
$_.Publisher -eq $identity.Publisher -and
[string]$_.Architecture -eq $identity.ProcessorArchitecture -and
[version]$_.Version -ge [version]$identity.Version
})
Comment thread
AmelBawa-msft marked this conversation as resolved.
if (-not $installed.Count) { $dependency }
}
)
$parameters = @{ Path = $bundle; ForceTargetApplicationShutdown = $true; ErrorAction = 'Stop' }
if ($dependencies.Count) { $parameters.DependencyPath = $dependencies }
Add-AppxPackage @parameters
Comment thread
AmelBawa-msft marked this conversation as resolved.
} else {
$package = Get-AppxPackage -Name Microsoft.DesktopAppInstaller |
Sort-Object Version -Descending | Select-Object -First 1
Expand All @@ -125,7 +149,7 @@ function Invoke-DevConfigWinGetDeployment {
}
exit 0
} catch {
[Console]::Error.WriteLine($_.ToString())
Write-Error -ErrorRecord $_ -ErrorAction Continue
exit 1
}
}
Expand Down Expand Up @@ -173,7 +197,7 @@ function Confirm-DevConfigWinGetReady {
try {
Get-WinGetPackage -Source winget -ErrorAction Stop | Out-Null
return
} catch [System.Runtime.InteropServices.COMException] {
} catch {
# 0x800706BA means the module could not reach WinGet's RPC server.
if ($_.Exception.HResult -ne -2147023174) { throw }
$moduleError = $_.Exception.Message
Comment thread
AmelBawa-msft marked this conversation as resolved.
Expand Down
Loading