Can find the registry of MSBuild 15.0

Viewed 1614

I have a old project, which is created by Visual Studio 2015, and I use a bat file to get the registry of MSBuild 14.0 in this project build event. Now I have to update my project to Visual Studio 2017, so I need to update the bat file to get the MSbuild 15.0, but I could not fins it.

In Visual Studio 2015: The registry path is:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\14.0

The value is:

C:\Program Files (x86)\MSBuild\14.0\Bin

But for Visual Studio 2017, I could not find the registry path.

How I get the registry value again for Visual Studio 2017?

1 Answers

How I get the registry value again for Visual Studio 2017?

You should to read following thread:

vswhere:

Over the years Visual Studio could be discovered using registry keys, but with recent changes to the deployment and extensibility models a new method is needed to discover possibly more than once installed instance. These changes facilitate a smaller, faster default install complimented by on-demand install of other workloads and components.

vswhere is designed to be a redistributable, single-file executable that can be used in build or deployment scripts to find where Visual Studio - or other products in the Visual Studio family - is located. For example, if you know the relative path to MSBuild, you can find the root of the Visual Studio install and combine the paths to find what you need.

vswhere is included with the installer as of Visual Studio 2017 version 15.2 and later, and can be found at the following location: %ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe.

And you use command like the following to find the latest version installed:

@echo off

for /f "usebackq tokens=1* delims=: " %%i in (`vswhere -latest -requires Microsoft.Component.MSBuild`) do (
  if /i "%%i"=="installationPath" set InstallDir=%%j
)

if exist "%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe" (
  "%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe" %*
)

Hope this helps.

Related