MSBuild 15 Tools Version not accepted

≡放荡痞女 提交于 2019-12-19 07:35:33

问题


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


回答1:


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


来源:https://stackoverflow.com/questions/46835599/msbuild-15-tools-version-not-accepted

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!