microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
22.88k stars 6.31k forks source link

How do I get details on how VCPKG_VISUAL_STUDIO_PATH is used? #22068

Closed thxkiwi closed 2 years ago

thxkiwi commented 2 years ago

I have created the discussion https://github.com/microsoft/vcpkg/discussions/20961

and not got any community or vcpkg team response in two months so I'm trying to contact the vcpkg team directly, here.

The overall issue I have is that I need to control where vcpkg finds the compiler/toolchain to use and am running into issues. If there is work that needs to be done I'm happy to contribute my time to resolving issues but I can find only few references to VCPKG_VISUAL_STUDIO_PATH in the https://github.com/microsoft/vcpkg repo and as such struggling to find how this is used internally and therefore why it complains that the location used does not contain a valid instance of the VS toolchain when location does.

Hoping we can work together to get this working.

Neumann-A commented 2 years ago

https://github.com/microsoft/vcpkg/blob/master/docs/users/triplets.md#vcpkg_visual_studio_path

the code for the selection itself is in vcpkg-tool.

used does not contain a valid instance

probably you did not install the English language pack. https://github.com/microsoft/vcpkg/blob/50fd3d9957195575849a49fa591e645f1d8e7156/README.md?plain=1#L70

thxkiwi commented 2 years ago

@Neumann-A are you or any of the team able to say specifically what it is that vcpkg looks for to determine whether VCPKG_VISUAL_STUDIO_PATH is valid in the eyes of vcpkg?

https://github.com/microsoft/vcpkg/blob/master/docs/users/triplets.md#vcpkg_visual_studio_path

the code for the selection itself is in vcpkg-tool.

I'll start grokking... but again if anyone can answer this question directly would be greatly appreciated since it isn't called out in the standard vcpkg documentation.

used does not contain a valid instance

probably you did not install the English language pack. https://github.com/microsoft/vcpkg/blob/50fd3d9957195575849a49fa591e645f1d8e7156/README.md?plain=1#L70

I thought that by default the VS installer(s) select the language based on the locale of the machine...

From https://docs.microsoft.com/en-us/visualstudio/install/use-command-line-parameters-to-install-visual-studio

--addProductLang | Optional: During an install or modify command, this repeatable parameter specifies the UI language packs that should be installed with the product. If not present, the installation uses the language pack that corresponds to the machine locale. For more information, see the List of language locales section on this page. -- | --

When I created the offline installer via --layout it contains all locales and language packs. If the validity of the VS instance is based on language pack then are you able to say exactly how to install Visual Studio to provide that specific VS component or VS workflow needed if the default option (based on the machine locale, which is en-US [see below]) is insufficient?

PS C:\> get-winsystemlocale

LCID             Name             DisplayName
----             ----             -----------
1033             en-US            English (United States)
Neumann-A commented 2 years ago

The complete selection code is in: https://github.com/microsoft/vcpkg-tool/blob/main/src/vcpkg/visualstudio.cpp

Neumann-A commented 2 years ago

Try setting VS160COMNTOOLS in your environment if it is not set and vswhere is not installed at const Path vswhere_exe = program_files_32_bit / "Microsoft Visual Studio" / "Installer" / "vswhere.exe";. From your example it should probably be pointing to: D:\Program Files\Microsoft Visual Studio\2019\BuildTools\Common7\Tools and make sure you have

                const auto cl_exe = path_root / "VC" / "bin" / "cl.exe";
                const auto vcvarsall_bat = path_root / "VC" / "vcvarsall.bat";

dumpbin and some other sub folders are also required further down the road but this at least should get you some instances being detected.

JackBoosY commented 2 years ago

Please note that variables like VCPKG_VISUAL_STUDIO_PATH are read-only, and modifications to them in the triplet file or portfile.cmake will not take effect. As @Neumann-A said, VCPKG_VISUAL_STUDIO_PATH is got according to vswhere.

JackBoosY commented 2 years ago

We hope your question was answered to your satisfaction; if it wasn't, you can reopen with more info.