Skip to content

Commit e04d058

Browse files
targosMylesBorins
authored andcommitted
build: default Windows build to Visual Studio 2019
Building and testing Node.js with Visual Studio 2019 is now working as expected. Fallback to VS 2017 if VS 2019 was not found. Fixes: #27214 PR-URL: #30022 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
1 parent e110d81 commit e04d058

File tree

2 files changed

+37
-36
lines changed

2 files changed

+37
-36
lines changed

BUILDING.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -498,9 +498,9 @@ $ backtrace
498498

499499
* [Python 2.7](https://www.python.org/downloads/)
500500
* The "Desktop development with C++" workload from
501-
[Visual Studio 2017](https://www.visualstudio.com/downloads/) or the
502-
"Visual C++ build tools" workload from the
503-
[Build Tools](https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017),
501+
[Visual Studio 2017 or 2019](https://visualstudio.microsoft.com/downloads/) or
502+
the "Visual C++ build tools" workload from the
503+
[Build Tools](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019),
504504
with the default optional components.
505505
* Basic Unix tools required for some tests,
506506
[Git for Windows](https://git-scm.com/download/win) includes Git Bash
@@ -513,7 +513,8 @@ $ backtrace
513513
Optional requirements to build the MSI installer package:
514514

515515
* The [WiX Toolset v3.11](https://wixtoolset.org/releases/) and the
516-
[Wix Toolset Visual Studio 2017 Extension](https://marketplace.visualstudio.com/items?itemName=RobMensching.WixToolsetVisualStudio2017Extension).
516+
[Wix Toolset Visual Studio 2017 Extension](https://marketplace.visualstudio.com/items?itemName=RobMensching.WixToolsetVisualStudio2017Extension)
517+
or the [Wix Toolset Visual Studio 2019 Extension](https://marketplace.visualstudio.com/items?itemName=WixToolset.WixToolsetVisualStudio2019Extension).
517518

518519
Optional requirements for compiling for Windows 10 on ARM (ARM64):
519520

vcbuild.bat

+32-32
Original file line numberDiff line numberDiff line change
@@ -236,61 +236,61 @@ if %target_arch%==x64 if %msvs_host_arch%==amd64 set vcvarsall_arg=amd64
236236
@rem also if both are x86
237237
if %target_arch%==x86 if %msvs_host_arch%==x86 set vcvarsall_arg=x86
238238

239-
@rem Look for Visual Studio 2017
240-
:vs-set-2017
241-
if defined target_env if "%target_env%" NEQ "vs2017" goto vs-set-2019
242-
echo Looking for Visual Studio 2017
243-
call tools\msvs\vswhere_usability_wrapper.cmd "[15.0,16.0)"
244-
if "_%VCINSTALLDIR%_" == "__" goto msbuild-not-found
239+
@rem Look for Visual Studio 2019
240+
:vs-set-2019
241+
if defined target_env if "%target_env%" NEQ "vs2019" goto vs-set-2017
242+
echo Looking for Visual Studio 2019
243+
call tools\msvs\vswhere_usability_wrapper.cmd "[16.0,17.0)"
244+
if "_%VCINSTALLDIR%_" == "__" goto vs-set-2017
245245
if defined msi (
246-
echo Looking for WiX installation for Visual Studio 2017...
246+
echo Looking for WiX installation for Visual Studio 2019...
247247
if not exist "%WIX%\SDK\VS2017" (
248-
echo Failed to find WiX install for Visual Studio 2017
249-
echo VS2017 support for WiX is only present starting at version 3.11
250-
goto msbuild-not-found
248+
echo Failed to find WiX install for Visual Studio 2019
249+
echo VS2019 support for WiX is only present starting at version 3.11
250+
goto vs-set-2017
251251
)
252252
if not exist "%VCINSTALLDIR%\..\MSBuild\Microsoft\WiX" (
253-
echo Failed to find the WiX Toolset Visual Studio 2017 Extension
254-
goto msbuild-not-found
253+
echo Failed to find the WiX Toolset Visual Studio 2019 Extension
254+
goto vs-set-2017
255255
)
256256
)
257-
@rem check if VS2017 is already setup, and for the requested arch
258-
if "_%VisualStudioVersion%_" == "_15.0_" if "_%VSCMD_ARG_TGT_ARCH%_"=="_%target_arch%_" goto found_vs2017
257+
@rem check if VS2019 is already setup, and for the requested arch
258+
if "_%VisualStudioVersion%_" == "_16.0_" if "_%VSCMD_ARG_TGT_ARCH%_"=="_%target_arch%_" goto found_vs2019
259259
@rem need to clear VSINSTALLDIR for vcvarsall to work as expected
260260
set "VSINSTALLDIR="
261261
@rem prevent VsDevCmd.bat from changing the current working directory
262262
set "VSCMD_START_DIR=%CD%"
263263
set vcvars_call="%VCINSTALLDIR%\Auxiliary\Build\vcvarsall.bat" %vcvarsall_arg%
264264
echo calling: %vcvars_call%
265265
call %vcvars_call%
266-
if errorlevel 1 goto msbuild-not-found
266+
if errorlevel 1 goto vs-set-2017
267267
if defined DEBUG_HELPER @ECHO ON
268-
:found_vs2017
268+
:found_vs2019
269269
echo Found MSVS version %VisualStudioVersion%
270-
set GYP_MSVS_VERSION=2017
271-
set PLATFORM_TOOLSET=v141
270+
set GYP_MSVS_VERSION=2019
271+
set PLATFORM_TOOLSET=v142
272272
goto msbuild-found
273273

274-
@rem Look for Visual Studio 2019
275-
:vs-set-2019
276-
if defined target_env if "%target_env%" NEQ "vs2019" goto msbuild-not-found
277-
echo Looking for Visual Studio 2019
278-
call tools\msvs\vswhere_usability_wrapper.cmd "[16.0,17.0)"
274+
@rem Look for Visual Studio 2017
275+
:vs-set-2017
276+
if defined target_env if "%target_env%" NEQ "vs2017" goto msbuild-not-found
277+
echo Looking for Visual Studio 2017
278+
call tools\msvs\vswhere_usability_wrapper.cmd "[15.0,16.0)"
279279
if "_%VCINSTALLDIR%_" == "__" goto msbuild-not-found
280280
if defined msi (
281-
echo Looking for WiX installation for Visual Studio 2019...
281+
echo Looking for WiX installation for Visual Studio 2017...
282282
if not exist "%WIX%\SDK\VS2017" (
283-
echo Failed to find WiX install for Visual Studio 2019
284-
echo VS2019 support for WiX is only present starting at version 3.11
283+
echo Failed to find WiX install for Visual Studio 2017
284+
echo VS2017 support for WiX is only present starting at version 3.11
285285
goto msbuild-not-found
286286
)
287287
if not exist "%VCINSTALLDIR%\..\MSBuild\Microsoft\WiX" (
288-
echo Failed to find the WiX Toolset Visual Studio 2019 Extension
288+
echo Failed to find the WiX Toolset Visual Studio 2017 Extension
289289
goto msbuild-not-found
290290
)
291291
)
292-
@rem check if VS2019 is already setup, and for the requested arch
293-
if "_%VisualStudioVersion%_" == "_16.0_" if "_%VSCMD_ARG_TGT_ARCH%_"=="_%target_arch%_" goto found_vs2019
292+
@rem check if VS2017 is already setup, and for the requested arch
293+
if "_%VisualStudioVersion%_" == "_15.0_" if "_%VSCMD_ARG_TGT_ARCH%_"=="_%target_arch%_" goto found_vs2017
294294
@rem need to clear VSINSTALLDIR for vcvarsall to work as expected
295295
set "VSINSTALLDIR="
296296
@rem prevent VsDevCmd.bat from changing the current working directory
@@ -300,10 +300,10 @@ echo calling: %vcvars_call%
300300
call %vcvars_call%
301301
if errorlevel 1 goto msbuild-not-found
302302
if defined DEBUG_HELPER @ECHO ON
303-
:found_vs2019
303+
:found_vs2017
304304
echo Found MSVS version %VisualStudioVersion%
305-
set GYP_MSVS_VERSION=2019
306-
set PLATFORM_TOOLSET=v142
305+
set GYP_MSVS_VERSION=2017
306+
set PLATFORM_TOOLSET=v141
307307
goto msbuild-found
308308

309309
:msbuild-not-found

0 commit comments

Comments
 (0)