From b0a0770aff6c63c578b7f75245386d547625f72f Mon Sep 17 00:00:00 2001 From: Duncan Horn Date: Wed, 10 Dec 2025 13:28:08 -0800 Subject: [PATCH 1/2] Use vswhere to find the latest VS install --- scripts/call-vcvars.cmd | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/scripts/call-vcvars.cmd b/scripts/call-vcvars.cmd index 924276b3..0f5dbce7 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 _VSWHERE= +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 _VSWHERE=%%i + +if "%_VSWHERE%"=="" 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 "%_VSWHERE%" %_ARCH% From 3a1d6373f9a4da469268aad39370a6527afecae5 Mon Sep 17 00:00:00 2001 From: Duncan Horn Date: Wed, 10 Dec 2025 13:37:21 -0800 Subject: [PATCH 2/2] Rename var to be clearer --- scripts/call-vcvars.cmd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/call-vcvars.cmd b/scripts/call-vcvars.cmd index 0f5dbce7..5511a979 100644 --- a/scripts/call-vcvars.cmd +++ b/scripts/call-vcvars.cmd @@ -2,10 +2,10 @@ REM NOTE: Intentionally not specifying 'setlocal' as we want the side-effects of calling 'vcvars' to affect the caller -set _VSWHERE= -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 _VSWHERE=%%i +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 "%_VSWHERE%"=="" echo ERROR: Unable to locate vcvarsall.bat & exit /B 1 +if "%_VCVARSALL%"=="" echo ERROR: Unable to locate vcvarsall.bat & exit /B 1 set _ARCH=%1 if /I "%_ARCH%"=="x86" ( @@ -13,4 +13,4 @@ if /I "%_ARCH%"=="x86" ( set _ARCH=x64_x86 ) -call "%_VSWHERE%" %_ARCH% +call "%_VCVARSALL%" %_ARCH%