replace Expand-Archive with .NET ZipFile for Sandbox stability
The `Expand-Archive` cmdlet fails in localized Windows Sandbox environments (e.g., de-DE) because the `Microsoft.PowerShell.Archive` module cannot find its localization resources (`ArchiveResources.psd1`) in the minimal OS image. Changes: - Replaced `Expand-Archive` with `[System.IO.Compression.ZipFile]::ExtractToDirectory` - Added `Add-Type -AssemblyName System.IO.Compression.FileSystem` to ensure .NET zip support - Added a safety check to ensure the Downloads directory existspull/16/head
parent
c33a3c70b7
commit
8095a09a7a
|
|
@ -81,6 +81,7 @@ function Install-WingetDependencies {
|
|||
$ProgressPreference = 'SilentlyContinue'
|
||||
|
||||
$downloadPath = Join-Path $env:USERPROFILE "Downloads"
|
||||
if (!(Test-Path $downloadPath)) { New-Item -ItemType Directory -Path $downloadPath }
|
||||
$latestRelease = Get-LatestRelease
|
||||
if (-not $latestRelease) { Write-Error "Could not retrieve the latest release. Exiting."; return; }
|
||||
|
||||
|
|
@ -125,8 +126,10 @@ if ($depsZipUrl) {
|
|||
|
||||
# Remove existing Dependencies folder and expand the zip
|
||||
if (Test-Path $topDepsFolder) { Remove-Item -Path $topDepsFolder -Recurse -Force }
|
||||
|
||||
Expand-Archive -LiteralPath $depsZipPath -DestinationPath $topDepsFolder -Force
|
||||
|
||||
# Replaces Expand archives with .NET System.IO.Compression
|
||||
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||
[System.IO.Compression.ZipFile]::ExtractToDirectory($depsZipPath, $topDepsFolder)
|
||||
}
|
||||
else { Write-Warning "No $depsZipName found in $latestTag, skipping dependency download."; }
|
||||
|
||||
|
|
@ -156,4 +159,3 @@ if ($removeMsStoreAsSource.IsPresent) {
|
|||
# Automatically accept source agreements to avoid prompts. Mostly applies to msstore.
|
||||
winget list --accept-source-agreements | Out-Null
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue