Skip to content

Old Powershell doesn't extract Zip files in Windows 10  #74

@Wihmajster

Description

@Wihmajster

Cmake, ninja, and task fail to install in Windows 10 because the Expand-Archive tool, used in extractZip function, requires files to have the zip extension. Adding it to the file before extracting it should fix the error.

PS C:\Users\WDAGUtilityAccount> .\setup_cpp_windows --cmake true --ninja true --task true                                                                                                 ::group::Installing cmake true
Installing cmake 3.23.1 x64 via direct downloading
Download and extract cmake 3.23.1
::debug::Downloading https://github.com/Kitware/CMake/releases/download/v3.23.1/cmake-3.23.1-windows-x86_64.zip
::debug::Destination C:\Users\WDAGUtilityAccount\AppData\Local\Temp\54ac4c22-6eea-403d-99e9-fcf92d7efa49
::debug::download complete
::debug::Using powershell at path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe                                                                                              [command]C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; if ((Get-Command -Name Expand-Archive -Module Microsoft.PowerShell.Archive -ErrorAction Ignore)) { Expand-Archive -LiteralPath 'C:\Users\WDAGUtilityAccount\AppData\Local\Temp\54ac4c22-6eea-403d-99e9-fcf92d7efa49' -DestinationPath 'C:\Users\WDAGUtilityAccount\cmake' -Force } else {[System.IO.Compression.ZipFile]::ExtractToDirectory('C:\Users\WDAGUtilityAccount\AppData\Local\Temp\54ac4c22-6eea-403d-99e9-fcf92d7efa49', 'C:\Users\WDAGUtilityAccount\cmake', $true) }"                     Expand-Archive :  is not a supported archive file format. .zip is the only supported archive file format.
At line:1 char:210
+ ...  Ignore)) { Expand-Archive -LiteralPath 'C:\Users\WDAGUtilityAccount\ ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:String) [Expand-Archive], IOException
    + FullyQualifiedErrorId : NotSupportedArchiveFileExtension,Expand-Archive

Error: Failed to download cmake 3.23.1 x64: Error: The process 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' failed with exit code 1
::endgroup::
took 8 seconds
::group::Installing ninja true
Installing ninja 1.10.2 x64 via direct downloading
Download and extract ninja 1.10.2
::debug::Downloading https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-win.zip
::debug::Destination C:\Users\WDAGUtilityAccount\AppData\Local\Temp\65b659cf-18f2-47c0-a1da-91bb82ee90b4
::debug::download complete
::debug::Using powershell at path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
[command]C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; if ((Get-Command -Name Expand-Archive -Module Microsoft.PowerShell.Archive -ErrorAction Ignore)) { Expand-Archive -LiteralPath 'C:\Users\WDAGUtilityAccount\AppData\Local\Temp\65b659cf-18f2-47c0-a1da-91bb82ee90b4' -DestinationPath 'C:\Users\WDAGUtilityAccount\ninja' -Force } else {[System.IO.Compression.ZipFile]::ExtractToDirectory('C:\Users\WDAGUtilityAccount\AppData\Local\Temp\65b659cf-18f2-47c0-a1da-91bb82ee90b4', 'C:\Users\WDAGUtilityAccount\ninja', $true) }"
Expand-Archive :  is not a supported archive file format. .zip is the only supported archive file format.
At line:1 char:210
+ ...  Ignore)) { Expand-Archive -LiteralPath 'C:\Users\WDAGUtilityAccount\ ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:String) [Expand-Archive], IOException
    + FullyQualifiedErrorId : NotSupportedArchiveFileExtension,Expand-Archive

Error: Failed to download ninja 1.10.2 x64: Error: The process 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' failed with exit code 1
::endgroup::
took 3 seconds
::group::Installing task true
Installing task 3.12.0 x64 via direct downloading
Download and extract task 3.12.0
::debug::Downloading https://github.com/go-task/task/releases/download/v3.12.0/task_windows_amd64.zip
::debug::Destination C:\Users\WDAGUtilityAccount\AppData\Local\Temp\7ec4a653-ba1a-4af6-acdf-c6a9df7e5cb6
::debug::download complete
::debug::Using powershell at path: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
[command]C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; if ((Get-Command -Name Expand-Archive -Module Microsoft.PowerShell.Archive -ErrorAction Ignore)) { Expand-Archive -LiteralPath 'C:\Users\WDAGUtilityAccount\AppData\Local\Temp\7ec4a653-ba1a-4af6-acdf-c6a9df7e5cb6' -DestinationPath 'C:\Users\WDAGUtilityAccount\task' -Force } else {[System.IO.Compression.ZipFile]::ExtractToDirectory('C:\Users\WDAGUtilityAccount\AppData\Local\Temp\7ec4a653-ba1a-4af6-acdf-c6a9df7e5cb6', 'C:\Users\WDAGUtilityAccount\task', $true) }"
Expand-Archive :  is not a supported archive file format. .zip is the only supported archive file format.
At line:1 char:210
+ ...  Ignore)) { Expand-Archive -LiteralPath 'C:\Users\WDAGUtilityAccount\ ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:String) [Expand-Archive], IOException
    + FullyQualifiedErrorId : NotSupportedArchiveFileExtension,Expand-Archive

Error: Failed to download task 3.12.0 x64: Error: The process 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' failed with exit code 1
::endgroup::
took 4 seconds
cmake failed to install
ninja failed to install
task failed to install
setup_cpp finished
Run `RefreshEnv.cmd` or restart your shell to update the environment.
PS C:\Users\WDAGUtilityAccount>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions