Refactor ZIP extraction for PowerShell compatibility#15692
Refactor ZIP extraction for PowerShell compatibility#15692showbiz2k wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Powershell core Expand-Archive cmdlet does not define the -DestinationPath parameter causing a failure to unpack. Powershell core uses -OutputPath instead.
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15692Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15692" |
There was a problem hiding this comment.
Pull request overview
Updates the Aspire CLI installer PowerShell script to handle ZIP extraction across Windows PowerShell vs PowerShell (Core), aiming to fix a parameter incompatibility when calling Expand-Archive.
Changes:
- Routes ZIP extraction through
Invoke-WithPowerShellVersionto call differentExpand-Archiveparameter names for modern vs legacy PowerShell.
| Expand-Archive -Path $ArchiveFile -DestinationPath $DestinationPath -Force -ErrorAction Stop | ||
|
|
||
| Invoke-WithPowerShellVersion -ModernAction { | ||
| Expand-Archive -Path $ArchiveFile -OutputPath $DestinationPath -Force -ErrorAction Stop |
There was a problem hiding this comment.
The ModernAction uses Expand-Archive -OutputPath, but elsewhere in this script (e.g., extension extraction) Expand-Archive is invoked with -DestinationPath under $Script:IsModernPowerShell. This inconsistency strongly suggests -OutputPath is not a valid parameter for the Expand-Archive available in pwsh, and will cause Windows installs under PowerShell Core to fail. Prefer keeping -DestinationPath for both branches, or (more robustly) select the parameter name by checking Get-Command Expand-Archive.Parameters for DestinationPath vs OutputPath.
| Expand-Archive -Path $ArchiveFile -OutputPath $DestinationPath -Force -ErrorAction Stop | |
| Expand-Archive -Path $ArchiveFile -DestinationPath $DestinationPath -Force -ErrorAction Stop |
Description
Powershell core Expand-Archive cmdlet does not define the -DestinationPath parameter causing a failure to unpack. Powershell core uses -OutputPath instead.
Checklist
<remarks />and<code />elements on your triple slash comments?aspire.devissue: