Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vcbuild.bat fails with Visual Studio 2017 #30118

Closed
richardlau opened this issue Oct 25, 2019 · 3 comments · Fixed by #30119
Closed

vcbuild.bat fails with Visual Studio 2017 #30118

richardlau opened this issue Oct 25, 2019 · 3 comments · Fixed by #30119
Labels
build Issues and PRs related to build files or the CI. windows Issues and PRs related to the Windows platform.

Comments

@richardlau
Copy link
Member

  • Version: master
  • Platform: Windows
  • Subsystem: build
C:\work\node\github\node>vcbuild
Looking for Python
Python 2 found in C:\Python27\\python.exe
Looking for NASM
Looking for Visual Studio 2019
calling: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\\Auxiliary\Build\vcvarsall.bat" amd64
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.9.3
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
Found MSVS version 15.0
configure  --dest-cpu=x64
Node configure: Found Python 2.7.13...
�[1m�[32mINFO�[0m: Using floating patch "tools/icu/patches/64/source/common/putil.cpp" from "tools/icu"
�[1m�[32mINFO�[0m: Using floating patch "tools/icu/patches/64/source/i18n/dtptngen.cpp" from "tools/icu"
Warning: Missing input files:
tools\v8_gypfiles\..\..\deps\v8\src\regexp\regexp-special-case.h
�[1m�[32mINFO�[0m: configure completed successfully
Project files generated.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.Cpp.Platform.targets(67,5): error MSB8020: The build tools for v142 (Platform Toolset = 'v142') can
not be found. To build using the v142 build tools, please install v142 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the
 solution, and then selecting "Retarget solution". [C:\work\node\github\node\deps\histogram\histogram.vcxproj]

Suspect #30022. I don't have VS2019 installed.

@richardlau
Copy link
Member Author

With DEBUG_HELPER=1

...
C:\work\node\github\node>SET VSWHERE_ARGS=-latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -version "[16.0,17.0)"

C:\work\node\github\node>for /F "usebackq tokens=*" %i in (`vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -version "[16.0,17.0)"`) do (
endlocal
 set "VCINSTALLDIR=%i\VC\"
 set "VS150COMNTOOLS=%i\Common7\Tools\"
 exit /B 0
)

C:\work\node\github\node>endlocal

C:\work\node\github\node>exit /B 1

C:\work\node\github\node>if "_C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\_" == "__" goto vs-set-2017

C:\work\node\github\node>if defined msi (
echo Looking for WiX installation for Visual Studio 2019...
 if not exist "C:\Program Files (x86)\WiX Toolset v3.11\\SDK\VS2017" (
echo Failed to find WiX install for Visual Studio 2019
 echo VS2019 support for WiX is only present starting at version 3.11
 goto vs-set-2017
)
 if not exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\\..\MSBuild\Microsoft\WiX" (
echo Failed to find the WiX Toolset Visual Studio 2019 Extension
 goto vs-set-2017
)
)

C:\work\node\github\node>if "_15.0_" == "_16.0_" if "_x64_" == "_x64_" goto found_vs2019

C:\work\node\github\node>set "VSINSTALLDIR="

C:\work\node\github\node>set "VSCMD_START_DIR=C:\work\node\github\node"

C:\work\node\github\node>set vcvars_call="C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\\Auxiliary\Build\vcvarsall.bat" amd64

C:\work\node\github\node>echo calling: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\\Auxiliary\Build\vcvarsall.bat" amd64
calling: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\\Auxiliary\Build\vcvarsall.bat" amd64

C:\work\node\github\node>call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\\Auxiliary\Build\vcvarsall.bat" amd64
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.9.3
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'

C:\work\node\github\node>echo Found MSVS version 15.0
Found MSVS version 15.0

C:\work\node\github\node>set GYP_MSVS_VERSION=2019

C:\work\node\github\node>set PLATFORM_TOOLSET=v142
...

@richardlau
Copy link
Member Author

Fix in #30119.

@richardlau richardlau changed the title vcbuild.bat fails with VS2017 vcbuild.bat fails with Visual Studio 2017 Oct 25, 2019
@richardlau richardlau added build Issues and PRs related to build files or the CI. windows Issues and PRs related to the Windows platform. labels Oct 25, 2019
@richardlau
Copy link
Member Author

After further investigation this problem only manifests if building from a Visual Studio 2017 command prompt. The VS 2017 command prompts set VCINSTALLDIR and having that set before calling vcbuild.bat was causing the detection logic to fail.

Running from a normal command prompt (without any of the Visual Studio environment variables set) works as expected.

#30119 fixes the Visual Studio command prompt case by clearing VCINSTALLDIR in vcbuild.bat.

targos pushed a commit that referenced this issue Nov 5, 2019
When run in a Visual Studio 2017 command prompt the `VCINSTALLDIR`
environment variable will be already set and is not cleared by the
`tools/msvs/vswhere_usability_wrapper.cmd` utility when it fails to
find Visual Studio 2019. This causes `vcbuild.bat` to incorrectly
assume Visual Studio 2019 and generate an incompatible configuration.

Clearing the value of `VCINSTALLDIR` before calling the utility fixes
the detection logic.

PR-URL: #30119
Fixes: #30118
Refs: #30022
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: João Reis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues and PRs related to build files or the CI. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant