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: #13911Fixes: #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‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ if /i "%1"=="/?" goto help
1515
setconfig=Release
1616
settarget=Build
1717
settarget_arch=x64
18-
settarget_env=vs2015
18+
settarget_env=
1919
setnoprojgen=
2020
setnobuild=
2121
setsign=
@@ -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+
ifdefined 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
setvcvars_call="%VCINSTALLDIR%\Auxiliary\Build\vcvarsall.bat"%vcvarsall_arg%
176176
echo calling: %vcvars_call%
177177
call%vcvars_call%
178-
178+
iferrorlevel1goto vs-set-2015
179179
:found_vs2017
180180
echo Found MSVS version %VisualStudioVersion%
181181
setGYP_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+
ifdefined target_env if"%target_env%"NEQ"vs2015"goto msbuild-not-found
188188
echo Looking for Visual Studio 2015
189189
ifnotdefined VS140COMNTOOLS goto msbuild-not-found
190190
ifnotexist"%VS140COMNTOOLS%\..\..\vc\vcvarsall.bat"goto msbuild-not-found
191-
echo Found Visual Studio 2015
192191
ifdefined msi (
193192
echo Looking for WiX installation for Visual Studio 2015...
194193
ifnotexist"%WIX%\SDK\VS2015" (
@@ -201,6 +200,8 @@ if defined msi (
201200
call"%VS140COMNTOOLS%\..\..\vc\vcvarsall.bat"
202201
SETVCVARS_VER=140
203202
ifnotdefined VCINSTALLDIR goto msbuild-not-found
203+
@rem Visual C++ Build Tools 2015 does not define VisualStudioVersion
204+
echo Found MSVS version 14.0
204205
setGYP_MSVS_VERSION=2015
205206
setPLATFORM_TOOLSET=v140
206207
goto msbuild-found

0 commit comments

Comments
(0)