fix(software): pass winget exe path into background jobs, add exit 3010 as OK
All checks were successful
release / build-and-release (push) Successful in 29s

Background jobs do not reliably inherit PATH from the parent session,
causing winget calls to fail silently. Now the resolved executable path
is passed explicitly as an argument into each Start-Job scriptblock.
Also treats exit code 3010 (success + reboot required) as OK.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
X9 Dev 2026-04-21 09:20:29 +02:00
parent e57fd6c5f2
commit 562f394137

View file

@ -31,8 +31,11 @@ $Config = Load-Config $ConfigPath
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
Write-Log "Checking winget availability" -Level INFO Write-Log "Checking winget availability" -Level INFO
$winget = Get-Command winget -ErrorAction SilentlyContinue $wingetExe = $null
if (-not $winget) { $wingetCmd = Get-Command winget -ErrorAction SilentlyContinue
if ($wingetCmd) {
$wingetExe = $wingetCmd.Source
} else {
# Try to find winget in known locations # Try to find winget in known locations
$wingetPaths = @( $wingetPaths = @(
"$env:LOCALAPPDATA\Microsoft\WindowsApps\winget.exe" "$env:LOCALAPPDATA\Microsoft\WindowsApps\winget.exe"
@ -40,19 +43,19 @@ if (-not $winget) {
) )
foreach ($p in $wingetPaths) { foreach ($p in $wingetPaths) {
$found = Get-Item $p -ErrorAction SilentlyContinue | Select-Object -First 1 $found = Get-Item $p -ErrorAction SilentlyContinue | Select-Object -First 1
if ($found) { $winget = $found.FullName; break } if ($found) { $wingetExe = $found.FullName; break }
} }
} }
if (-not $winget) { if (-not $wingetExe) {
Write-Log "winget not found - software installation skipped" -Level ERROR Write-Log "winget not found - software installation skipped" -Level ERROR
exit 1 exit 1
} }
Write-Log "winget found: $($winget.Source -or $winget)" -Level OK Write-Log "winget found: $wingetExe" -Level OK
# Accept agreements upfront # Accept agreements upfront
& winget source update --accept-source-agreements 2>&1 | Out-Null & $wingetExe source update --accept-source-agreements 2>&1 | Out-Null
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
# Install packages from config # Install packages from config
@ -68,9 +71,9 @@ if (Get-Feature $Config "software" "wingetInstalls") {
$jobs = @() $jobs = @()
foreach ($pkg in $packages) { foreach ($pkg in $packages) {
Write-Log " Starting: $($pkg.name) ($($pkg.wingetId))" -Level INFO Write-Log " Starting: $($pkg.name) ($($pkg.wingetId))" -Level INFO
$jobs += Start-Job -ArgumentList $pkg.wingetId, $pkg.name -ScriptBlock { $jobs += Start-Job -ArgumentList $pkg.wingetId, $pkg.name, $wingetExe -ScriptBlock {
param($wingetId, $name) param($wingetId, $name, $wingetExe)
$output = & winget install --id $wingetId ` $output = & $wingetExe install --id $wingetId `
--silent ` --silent `
--accept-package-agreements ` --accept-package-agreements `
--accept-source-agreements ` --accept-source-agreements `
@ -91,7 +94,7 @@ if (Get-Feature $Config "software" "wingetInstalls") {
foreach ($job in $jobs) { foreach ($job in $jobs) {
$r = Receive-Job -Job $job $r = Receive-Job -Job $job
if ($r.ExitCode -eq 0) { if ($r.ExitCode -eq 0 -or $r.ExitCode -eq 3010) {
Write-Log " Installed OK: $($r.Name)" -Level OK Write-Log " Installed OK: $($r.Name)" -Level OK
} elseif ($r.ExitCode -eq -1978335189) { } elseif ($r.ExitCode -eq -1978335189) {
Write-Log " Already installed: $($r.Name)" -Level OK Write-Log " Already installed: $($r.Name)" -Level OK