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

Where visualstudio2019buildtools is installed? #117

Closed
aminya opened this issue Sep 16, 2021 · 8 comments
Closed

Where visualstudio2019buildtools is installed? #117

aminya opened this issue Sep 16, 2021 · 8 comments

Comments

@aminya
Copy link

aminya commented Sep 16, 2021

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

    invalid parameters
    [ERROR:vcvars.bat] Toolset directory for version '15.9' was not found.
    [ERROR:VsDevCmd.bat] *** VsDevCmd.bat encountered errors. Environment may be incomplete and/or incorrect. ***
    [ERROR:VsDevCmd.bat] In an uninitialized command prompt, please 'set VSCMD_DEBUG=[value]' and then re-run
    [ERROR:VsDevCmd.bat] vsdevcmd.bat [args] for additional details.
    [ERROR:VsDevCmd.bat] Where [value] is:
    [ERROR:VsDevCmd.bat]    1 : basic debug logging
    [ERROR:VsDevCmd.bat]    2 : detailed debug logging
    [ERROR:VsDevCmd.bat]    3 : trace level logging. Redirection of output to a file when using this level is recommended.
    [ERROR:VsDevCmd.bat] Example: set VSCMD_DEBUG=3
    [ERROR:VsDevCmd.bat]          vsdevcmd.bat > vsdevcmd.trace.txt 2>&1

https://github.com/aminya/setup-cpp/runs/3618796745?check_suite_focus=true#step:7:302

@jberezanski
Copy link
Owner

jberezanski commented Sep 16, 2021

https://github.com/aminya/setup-cpp/blob/7fdcafd80517c9878f7cd4b8dc0ef296a6836070/src/msvc/msvc.ts#L51

      "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.

@jberezanski
Copy link
Owner

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).

@jberezanski
Copy link
Owner

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.)

@jberezanski
Copy link
Owner

jberezanski commented Sep 16, 2021

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 --includeRecommended
  • MSVC 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"

@aminya
Copy link
Author

aminya commented Sep 17, 2021

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

@jberezanski
Copy link
Owner

jberezanski commented Sep 17, 2021

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.

@jberezanski
Copy link
Owner

Looking at https://github.com/aminya/setup-cpp/runs/3635436051 I can see more issues:

  • you are still passing the invalid workload id;
  • the actual installation of VS fails - you should inspect the numerous log files generated by the VS installer ($Env:TEMP\chocolatey\dd_*.log) to determine the cause;
  • why did you put the package parameters in single quotes in addition to the outer double quotes? I have never encountered the need to to such double quoting and I'm not sure if it will not confuse the package parameters parser.

One more suggestion: if you enable the verbose and debug output of choco (-d -v) then the log might contain additional clues.

@jberezanski
Copy link
Owner

Closing due to inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants