@@ -25,19 +25,6 @@ SET pub_cache_path=%FLUTTER_ROOT%\.pub-cache
2525
2626SET dart = %dart_sdk_path% \bin\dart.exe
2727
28- REM Detect which PowerShell executable is available on the Host
29- REM PowerShell version < = 5: PowerShell.exe
30- REM PowerShell version > = 6: pwsh.exe
31- WHERE /Q pwsh.exe && (
32- SET powershell_executable = pwsh.exe
33- ) || WHERE /Q PowerShell.exe && (
34- SET powershell_executable = PowerShell.exe
35- ) || (
36- ECHO Error: PowerShell executable not found. 1 >& 2
37- ECHO Either pwsh.exe or PowerShell.exe must be in your PATH. 1 >& 2
38- EXIT 1
39- )
40-
4128REM Ensure that bin/cache exists.
4229IF NOT EXIST " %cache_dir% " MKDIR " %cache_dir% "
4330
@@ -66,9 +53,18 @@ GOTO :after_subroutine
6653 CALL " %bootstrap_path% "
6754 )
6855
69- PUSHD " %flutter_root% "
70- FOR /f %%r IN ('git rev-parse HEAD') DO SET revision = %%r
71- POPD
56+ REM Check that git exists and get the revision
57+ SET git_exists = false
58+ 2 > NUL (
59+ PUSHD " %flutter_root% "
60+ FOR /f %%r IN ('git rev-parse HEAD') DO (
61+ SET git_exists = true
62+ SET revision = %%r
63+ )
64+ POPD
65+ )
66+ REM If git didn't execute we don't have git. Exit without /B to avoid retrying.
67+ if %git_exists% == false echo Error: Unable to find git in your PATH. && EXIT 1
7268 SET compilekey = " %revision% :%FLUTTER_TOOL_ARGS% "
7369
7470 REM Invalidate cache if:
@@ -101,6 +97,18 @@ GOTO :after_subroutine
10197 EXIT /B
10298
10399 :do_sdk_update_and_snapshot
100+ REM Detect which PowerShell executable is available on the Host
101+ REM PowerShell version < = 5: PowerShell.exe
102+ REM PowerShell version > = 6: pwsh.exe
103+ WHERE /Q pwsh.exe && (
104+ SET powershell_executable = pwsh.exe
105+ ) || WHERE /Q PowerShell.exe && (
106+ SET powershell_executable = PowerShell.exe
107+ ) || (
108+ ECHO Error: PowerShell executable not found. 1 >& 2
109+ ECHO Either pwsh.exe or PowerShell.exe must be in your PATH. 1 >& 2
110+ EXIT 1
111+ )
104112 ECHO Checking Dart SDK version... 1 >& 2
105113 SET update_dart_bin = %FLUTTER_ROOT% \bin\internal\update_dart_sdk.ps1
106114 REM Escape apostrophes from the executable path
0 commit comments