Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSBuild 15 Tools Version not accepted

I have installed the MSBuild (15.4.0) tools for Visual Studio 2017 on a build server. To do this I used the link entitled "Build Tools for Visual Studio 2017" from Visual Studio Downloads

The path to the MSBuild.exe is:

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin

I have added this path to the Environment Variable 'path'.

I have a powershell script with the following as the body for the build task:

msbuild '..\MyApplication.sln' /t:Build /tv:15.0 /p:GenerateBuildInfoConfigFile=false /p:Configuration=Release /p:RunCodeAnalysis=True /p:VisualStudioVersion=15.0

But, when this is executed (all handled by TeamCity) I find the following in the LOG:

MSBUILD : error MSB1040: ToolsVersion is not valid. The tools version "15.0" is unrecognized. Available tools versions are "2.0", "3.5", "4.0".

The documentation suggests 15.0 should be correct.

EDIT From the 2017 documentation on What's New in MSBuild 15 it states:

MSBuildToolsVersion for this version of the tools is 15.0. The assembly version is 15.1.0.0.

However, the 2017 documentation MSBuild Command Line Reference states:

For MSBuild 4.5, you can specify the following values for version: 2.0, 3.5, and 4.0. If you specify 4.0, the VisualStudioVersion build property specifies which sub-toolset to use. For more information, see the Sub-toolsets section of Toolset (ToolsVersion).

So I'm a bit confused by the nomenclature: MSBuild 15 or MSBuild 4.5...?

like image 813
DrGriff Avatar asked Oct 19 '17 17:10

DrGriff


People also ask

How do I use specific version of MSBuild?

Use 'where msbuild' to determine where it is loading msbuild from. Use the Visual Studio Command Prompt (2010) shortcut to initialize the path and other environment variables for VS 2010 and MSBuild 4.0. Don't forget, older MSBuild versions are also updated when newer .

How do I check MSBuild Tools version?

Starting in Visual Studio 2013, the MSBuild Toolset version is the same as the Visual Studio version number. MSBuild defaults to this Toolset within Visual Studio and on the command line, regardless of the Toolset version specified in the project file. This behavior can be overridden by using the -ToolsVersion flag.

Where is MSBuild 15 located?

MSBuild is now installed in a folder under each version of Visual Studio. For example, C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild. You can also use the following PowerShell module to locate MSBuild: vssetup. powershell.


1 Answers

I finally found a fix. It was the path that was incorrect.

The solution was to change the powershell line above to:

$msbuild = 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\msbuild.exe'
    & msbuild '..\MyApplication.sln' /t:Build /m /p:GenerateBuildInfoConfigFile=false /p:Configuration=Release /p:RunCodeAnalysis=True /p:VisualStudioVersion=15.0
like image 117
DrGriff Avatar answered Oct 31 '22 08:10

DrGriff