Skip to content

Commit fd995c1

Browse files
committed
Update install_script to support VS2022.
1 parent 1ff70a3 commit fd995c1

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

install_script.bat

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ if "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
4141
REM Check if already running in an environment with VS setup
4242
if defined VCINSTALLDIR (
4343
if defined VisualStudioVersion (
44-
if "%VisualStudioVersion%"=="16.0" (
44+
if "%VisualStudioVersion%"=="17.0" (
45+
echo Existing Visual Studio 2022 environment detected...
46+
set MSVC_VER=16
47+
goto MSVCVarsDone
48+
) else if "%VisualStudioVersion%"=="16.0" (
4549
echo Existing Visual Studio 2019 environment detected...
4650
set MSVC_VER=16
4751
goto MSVCVarsDone
@@ -81,6 +85,16 @@ if not exist "%SCRIPTDIR%\vswhere.exe" (
8185
:VSwhereDetection
8286
REM Use vswhere to list detected installs
8387
for /f "usebackq tokens=* delims=" %%i in (`"%SCRIPTDIR%\vswhere.exe" -prerelease -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do (
88+
for /f "delims=" %%a in ('echo %%i ^| find "2022"') do (
89+
if not "%%a"=="" (
90+
echo Visual Studio 2022 environment detected...
91+
call "%~0" "17" "%%i"
92+
if not ERRORLEVEL 1 (
93+
set MSVC17=1
94+
set MSVCFOUND=1
95+
)
96+
)
97+
)
8498
for /f "delims=" %%a in ('echo %%i ^| find "2019"') do (
8599
if not "%%a"=="" (
86100
echo Visual Studio 2019 environment detected...
@@ -220,7 +234,9 @@ if "%SYSARCH%"=="32" (
220234
goto Terminate
221235
)
222236
REM Call the required vcvars file in order to setup up build locations
223-
if "%MSVC_VER%"=="16" (
237+
if "%MSVC_VER%"=="17" (
238+
set VCVARS=%2\VC\Auxiliary\Build\vcvars%SYSARCH%.bat
239+
) else if "%MSVC_VER%"=="16" (
224240
set VCVARS=%2\VC\Auxiliary\Build\vcvars%SYSARCH%.bat
225241
) else if "%MSVC_VER%"=="15" (
226242
set VCVARS=%2\VC\Auxiliary\Build\vcvars%SYSARCH%.bat
@@ -250,7 +266,9 @@ if not ERRORLEVEL 1 (
250266
)
251267
set /p MSBUILDDIR=<"%SCRIPTDIR%\msbuild.txt"
252268
del /F /Q "%SCRIPTDIR%\msbuild.txt" >nul 2>&1
253-
if "%MSVC_VER%"=="16" (
269+
if "%MSVC_VER%"=="17" (
270+
set VCTargetsPath="..\..\..\Microsoft\VC\v170\BuildCustomizations"
271+
) else if "%MSVC_VER%"=="16" (
254272
set VCTargetsPath="..\..\Microsoft\VC\v160\BuildCustomizations"
255273
) else if "%MSVC_VER%"=="15" (
256274
set VCTargetsPath="..\..\..\Common7\IDE\VC\VCTargets\BuildCustomizations"
@@ -264,8 +282,16 @@ if "%MSVC_VER%"=="16" (
264282

265283
REM Convert the relative targets path to an absolute one
266284
set CURRDIR=%CD%
267-
pushd %MSBUILDDIR%
268-
pushd %VCTargetsPath%
285+
pushd %MSBUILDDIR% 2>nul
286+
if %ERRORLEVEL% neq 0 (
287+
echo Error: Failed to get correct msbuild path!
288+
goto Terminate
289+
)
290+
pushd %VCTargetsPath% 2>nul
291+
if %ERRORLEVEL% neq 0 (
292+
echo Error: Unknown VCTargetsPath path!
293+
goto Terminate
294+
)
269295
set VCTargetsPath=%CD%
270296
popd
271297
popd

0 commit comments

Comments
 (0)