Unverified Commit 1021a52f authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] exit script if powershell version detection fails (#64773)

parent b5ed913e
......@@ -92,7 +92,13 @@ GOTO :after_subroutine
SET update_dart_bin=%FLUTTER_ROOT%/bin/internal/update_dart_sdk.ps1
REM Escape apostrophes from the executable path
SET "update_dart_bin=!update_dart_bin:'=''!"
%powershell_executable% -ExecutionPolicy Bypass -Command "Unblock-File -Path '%update_dart_bin%'; & '%update_dart_bin%'"
REM PowerShell command must have exit code set in order to prevent all non-zero exit codes from being translated
REM into 1. The exit code 2 is used to detect the case where the major version is incorrect and there should be
REM no subsequent retries.
%powershell_executable% -ExecutionPolicy Bypass -Command "Unblock-File -Path '%update_dart_bin%'; & '%update_dart_bin%'; exit $LASTEXITCODE;"
IF "%ERRORLEVEL%" EQU "2" (
EXIT 1
)
IF "%ERRORLEVEL%" NEQ "0" (
ECHO Error: Unable to update Dart SDK. Retrying...
timeout /t 5 /nobreak
......
......@@ -29,7 +29,9 @@ $psMajorVersionLocal = $PSVersionTable.PSVersion.Major
if ($psMajorVersionLocal -lt $psMajorVersionRequired) {
Write-Host "Flutter requires PowerShell $psMajorVersionRequired.0 or newer."
Write-Host "See https://flutter.dev/docs/get-started/install/windows for more."
return
Write-Host "Current version is $psMajorVersionLocal."
# Use exit code 2 to signal that shared.bat should exit immediately instead of retrying.
exit 2
}
if ((Test-Path $engineStamp) -and ($engineVersion -eq (Get-Content $engineStamp))) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment