diff --git a/scripts/call-vcvars.cmd b/scripts/call-vcvars.cmd index 924276b3..5511a979 100644 --- a/scripts/call-vcvars.cmd +++ b/scripts/call-vcvars.cmd @@ -1,17 +1,16 @@ @echo off -:: NOTE: Intentionally not specifying 'setlocal' as we want the side-effects of calling 'vcvars' to affect the caller +REM NOTE: Intentionally not specifying 'setlocal' as we want the side-effects of calling 'vcvars' to affect the caller -:: NOTE: This is primarily intended to be used by the build pipelines, hence the hard-coded paths, and might not be -:: generally useful. The following check is intended to help diagnose such possible issues -if NOT EXIST "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" ( - echo ERROR: Could not locate 'vcvars' batch file. This script is intended to be run from a build machine & exit /B 1 -) +set _VCVARSALL= +for /f "delims=" %%i in ('"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -products * -latest -find VC\Auxiliary\Build\vcvarsall.bat') do set _VCVARSALL=%%i + +if "%_VCVARSALL%"=="" echo ERROR: Unable to locate vcvarsall.bat & exit /B 1 -set ARCH=%1 -if /I "%ARCH%"=="x86" ( +set _ARCH=%1 +if /I "%_ARCH%"=="x86" ( REM Use the x64 toolchain - set ARCH=x64_x86 + set _ARCH=x64_x86 ) -call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" %ARCH% +call "%_VCVARSALL%" %_ARCH%