Closed aminya closed 1 year ago
"add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended --passive",
I'm pretty certain there should be a --
before add
. The way visualstudio2019buildtools package parameters parsing works is that all switches are recognized by the "--" prefix and other text (not related to a switch) is ignored. So basically the VS installer was not told to install the workload.
Second issue: "Microsoft.VisualStudio.Workload.NativeDesktop" is the id of the workload for the full IDE, not for Build Tools. For Build Tools you probably want the "Microsoft.VisualStudio.Workload.VCTools" workload (see https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2019&preserve-view=true#desktop-development-with-c).
Lastly, I suggest installing the workload using its own addon package: visualstudio2019-workload-vctools
instead of passing --add in the main package parameters. This both reduces the complexity of package parameters and makes the installation more reliable in certain circumstances.
(To be clear: install both packages, first visualstudio2019buildtools (no parameters needed), then visualstudio2019-workload-vctools with --includeRecommended
.)
After fixing the workload installation, I can see that this toolset version gets installed: 14.29.30133
(C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133)
but your script uses toolset = "16.11.2.0"
. I'm not a VC++ developer, but I believe the toolset version is something separate from the Visual Studio version, which you seem to be passing here.
From the Visual Studio Installer I can select these toolsets to install:
MSVC v142 - VS 2019 C++ x64/x86 build tools (Latest)
- 14.29, installed by default with --includeRecommendedMSVC v141 - VS 2017 C++ x64/x86 build tools (v14.16)
MSVC v140 - VS 2015 C++ build tools (v14.00)
which suggests to me that valid toolset versions that can be passed to vcvarsall.bat are "14.29", "14.16" and "14.0"
I tried your suggestions, but the issue was not fixed. Not sure what to do. I merged some patches for now so we are one step closer to make this work.
https://github.com/aminya/setup-cpp/blob/master/src/msvc/msvc.ts
I suggest you try installing the packages by hand (just typing the choco commands and the vcvarsall.bat invocation into cmd) on a clean system and inspect the result. Also, I would expect the third version segment of the toolset to change rapidly (possibly with each minor VS update), so hardcoded "14.29.30133" will probably stop working once a new VS 2019 update is released. The choco packages always install the latest released VS 2017/2019 version (regardless of the package version number), so unless you are installing from a precreated offline layout (and you are not), there is no control over the exact VS version that will be installed.
Looking at https://github.com/aminya/setup-cpp/runs/3635436051 I can see more issues:
$Env:TEMP\chocolatey\dd_*.log
) to determine the cause;One more suggestion: if you enable the verbose and debug output of choco (-d -v
) then the log might contain additional clues.
Closing due to inactivity.
I am working on a project that automates setting up a Cpp development environment. I am using visualstudio2017buildtools and visualstudio2019buildtools to set up MSVC. However, my tests fail because vcvars.bat cannot find the toolset. Could you help me with this?
https://github.com/aminya/setup-cpp
https://github.com/aminya/setup-cpp/runs/3618796745?check_suite_focus=true#step:7:302