Figuring out %VCToolsVersion% without VsDevCmd.bat in new(ish) Visual Studios

154 Views Asked by At

I'm trying to add support for Visual Studio 2022 to an ancient build script that so far supports only VS 2015. I've figured out that I need to use vswhere to find where the product itself is installed -- but how can I figure out what is VCToolsVersion value? I need that to be able to specify include path, which for example is:

C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.36.32532\atlmfc\include\

And the only way I've figured out to get this version number 14.36.32532 is using VCToolsVersion. I'd like to do this without using VsDevCmd.bat because this is a python script, and parsing environment variables from an external .bat file doesn't sound the correct way.

I also tried these, which I thought would give me the path:

vswhere -requires Microsoft.VisualStudio.Component.ATL
vswhere -requires Microsoft.VisualStudio.Component.VC.ATLMFC

these return nothing, and this:

vswhere -requires Microsoft.VisualStudio.Component.VC.ATL

Just returns the path to VS and not really anything that would help me to figure out the include path. All these just seem to return VS root dir, and version numbers for something else.

instanceId: d2d572c6
installDate: 9.3.2023 9.37.04
installationName: VisualStudio/17.6.2+33723.286
installationPath: C:\Program Files\Microsoft Visual Studio\2022\Enterprise
installationVersion: 17.6.33723.286
productId: Microsoft.VisualStudio.Product.Enterprise
productPath: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\devenv.exe
state: 4294967295
isComplete: 1
isLaunchable: 1
isPrerelease: 0
isRebootRequired: 0
displayName: Visual Studio Enterprise 2022
description: Scalable, end-to-end solution for teams of any size
channelId: VisualStudio.17.Release
channelUri: https://aka.ms/vs/17/release/channel
enginePath: C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\ServiceHub\Services\Microsoft.VisualStudio.Setup.Service
installedChannelId: VisualStudio.17.Release
installedChannelUri: https://aka.ms/vs/17/release/channel
releaseNotes: https://docs.microsoft.com/en-us/visualstudio/releases/2022/release-notes-v17.6#17.6.2
thirdPartyNotices: https://go.microsoft.com/fwlink/?LinkId=661288
updateDate: 2023-06-05T11:06:15.2023338Z
catalog_buildBranch: d17.6
catalog_buildVersion: 17.6.33723.286
catalog_id: VisualStudio/17.6.2+33723.286
catalog_localBuild: build-lab
catalog_manifestName: VisualStudio
catalog_manifestType: installer
catalog_productDisplayVersion: 17.6.2
catalog_productLine: Dev17
catalog_productLineVersion: 2022
catalog_productMilestone: RTW
catalog_productMilestoneIsPreRelease: False
catalog_productName: Visual Studio
catalog_productPatchVersion: 2
catalog_productPreReleaseMilestoneSuffix: 1.0
catalog_productSemanticVersion: 17.6.2+33723.286
catalog_requiredEngineVersion: 3.6.2115.31769
properties_campaignId: 2030:6aae985218a94479a0432471b62643c0
properties_channelManifestId: VisualStudio.17.Release/17.6.2+33723.286
properties_nickname: 2

Is there a proper way (or even a small kludge) to get the correct path / version number?

Edit

Of course right after posting this I found file Microsoft.VCToolsVersion.default.txt in ...\VC\Auxiliary\Build dir, which contains the version number, and I think that is what I should be using.

1

There are 1 best solutions below

0
James Z On

The version number can be found from file Microsoft.VCToolsVersion.default.txt which exists under Visual Studio installation (get the path with vswhere), in ...\VC\Auxiliary\Build