Repository navigation
Ensure compatibility with older PowerShell versions and better error handling - #8652
Conversation
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.
| SET exit_code=%ERRORLEVEL% | ||
| IF %exit_code% NEQ 0 ( | ||
| ECHO Error: Unable to update Dart SDK. | ||
| REM Do not use /B here, we want to exit out of the script, not just the subroutine |
There was a problem hiding this comment.
why do you put this comment here but not elsewhere?
There was a problem hiding this comment.
This is the only place where it matters: we are inside a subroutine and we want to exit the entire script. In the other places where I removed the /B, it didn't actually change any logic because we weren't in a subroutine (I just removed it to be consistent: in case of error, exit the script).
| Expand-Archive $dartSdkZip -DestinationPath $cachePath | ||
| if (Get-Command Expand-Archive -errorAction SilentlyContinue) { | ||
| # Expand-Archive requires PowerShell 5 or newer | ||
| Expand-Archive $dartSdkZip -DestinationPath $cachePath |
There was a problem hiding this comment.
why do we prefer Expand-Archive on newer powershells?
There was a problem hiding this comment.
Expand-Archive is the recommended (and only official) way to expand archives in a PowerShell script. The alternative I provide here for older PowerShells is kinda hacky, as it calls out to the Windows GUI to do the unzipping (it will actually pop up a new GUI window displaying the unzipping status).
|
Travis is failing with infrastructure problems unrelated to this PR (this PR doesn't touch any code that executes on Travis). |
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.