Skip to content

Commit cd9ef93

Browse files
joaocgreisaddaleax
authored andcommitted
build,win: use latest installed VS by default
vcbuild.bat should detect what version of Visual Studio to use, it should simply work without any parameter if any supported version is installed. It should default to the latest version, to match the behavior of `node-gyp`. PR-URL: #13911 Fixes: #13641 Reviewed-By: Refael Ackermann <[email protected]>
1 parent 6eb53e5 commit cd9ef93

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

vcbuild.bat

+7-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ if /i "%1"=="/?" goto help
1515
set config=Release
1616
set target=Build
1717
set target_arch=x64
18-
set target_env=vs2015
18+
set target_env=
1919
set noprojgen=
2020
set nobuild=
2121
set sign=
@@ -164,18 +164,18 @@ if %target_arch%==x64 if %msvs_host_arch%==amd64 set vcvarsall_arg=amd64
164164

165165
@rem Look for Visual Studio 2017
166166
:vs-set-2017
167-
if "%target_env%" NEQ "vs2017" goto vs-set-2015
167+
if defined target_env if "%target_env%" NEQ "vs2017" goto vs-set-2015
168168
echo Looking for Visual Studio 2017
169169
@rem check if VS2017 is already setup, and for the requested arch
170170
if "_%VisualStudioVersion%_" == "_15.0_" if "_%VSCMD_ARG_TGT_ARCH%_"=="_%target_arch%_" goto found_vs2017
171+
@rem need to clear VSINSTALLDIR for vcvarsall to work as expected
171172
set "VSINSTALLDIR="
172173
call tools\msvs\vswhere_usability_wrapper.cmd
173174
if "_%VCINSTALLDIR%_" == "__" goto vs-set-2015
174-
@rem need to clear VSINSTALLDIR for vcvarsall to work as expected
175175
set vcvars_call="%VCINSTALLDIR%\Auxiliary\Build\vcvarsall.bat" %vcvarsall_arg%
176176
echo calling: %vcvars_call%
177177
call %vcvars_call%
178-
178+
if errorlevel 1 goto vs-set-2015
179179
:found_vs2017
180180
echo Found MSVS version %VisualStudioVersion%
181181
set GYP_MSVS_VERSION=2017
@@ -184,11 +184,10 @@ goto msbuild-found
184184

185185
@rem Look for Visual Studio 2015
186186
:vs-set-2015
187-
if "%target_env%" NEQ "vs2015" goto msbuild-not-found
187+
if defined target_env if "%target_env%" NEQ "vs2015" goto msbuild-not-found
188188
echo Looking for Visual Studio 2015
189189
if not defined VS140COMNTOOLS goto msbuild-not-found
190190
if not exist "%VS140COMNTOOLS%\..\..\vc\vcvarsall.bat" goto msbuild-not-found
191-
echo Found Visual Studio 2015
192191
if defined msi (
193192
echo Looking for WiX installation for Visual Studio 2015...
194193
if not exist "%WIX%\SDK\VS2015" (
@@ -201,6 +200,8 @@ if defined msi (
201200
call "%VS140COMNTOOLS%\..\..\vc\vcvarsall.bat"
202201
SET VCVARS_VER=140
203202
if not defined VCINSTALLDIR goto msbuild-not-found
203+
@rem Visual C++ Build Tools 2015 does not define VisualStudioVersion
204+
echo Found MSVS version 14.0
204205
set GYP_MSVS_VERSION=2015
205206
set PLATFORM_TOOLSET=v140
206207
goto msbuild-found

0 commit comments

Comments
 (0)