Ensure compatibility with older PowerShell versions and better error handling (#8652)

This should make our scripts compatible with PowerShell 2 or newer. PowerShell 2 was released in October 2009 and shipped with Windows 7 as default. (I suspect the scripts are now also compatible with PowerShell 1, but that's unconfirmed). This fixes #8606.

The PR also introduces better error handling when Flutter fail to download the Dart SDK to fix #8627.
This commit is contained in:
Michael Goderbauer
2017-03-08 10:52:07 -08:00
committed by GitHub
parent 0136b965e8
commit e2dccc5e48
3 changed files with 24 additions and 5 deletions

View File

@@ -44,7 +44,16 @@ Import-Module BitsTransfer
Start-BitsTransfer -Source $dartSdkUrl -Destination $dartSdkZip
Write-Host "Unzipping Dart SDK..."
Expand-Archive $dartSdkZip -DestinationPath $cachePath
if (Get-Command Expand-Archive -errorAction SilentlyContinue) {
# Expand-Archive requires PowerShell 5 or newer
Expand-Archive $dartSdkZip -DestinationPath $cachePath
} else {
$shell = New-Object -com shell.application
$zip = $shell.NameSpace($dartSdkZip)
foreach($item in $zip.items()) {
$shell.Namespace($cachePath).copyhere($item)
}
}
Remove-Item $dartSdkZip
$dartSdkVersion | Out-File $dartSdkStampPath -Encoding ASCII