2017-10-19 94 views
2

我已经在构建服务器上为Visual Studio 2017安装了MSBuild(15.4.0)工具。要做到这一点,我用了题为 “构建工具为Visual Studio 2017年” 的链接从Visual Studio DownloadsMSBuild 15工具版本不被接受

到MSBuild.exe的路径是:

C:\ Program Files文件(x86)的\微软的Visual Studio的 \ 2017 \ BuildTools \ MSBuild \ 15.0 \ Bin

我已经将此路径添加到环境变量“路径”。

我有因为身体下面为构建任务PowerShell脚本:

的MSBuild '.. \ MyApplication.sln'/吨:构建/tv:15.0 /P:GenerateBuildInfoConfigFile = FALSE/p:配置=释放 /p:RunCodeAnalysis =真/p:VisualStudioVersion=15.0

但是,当这被执行(全部由TeamCity的处理)我发现在日志中的以下内容:

MSBUILD:错误MSB1040:ToolsVersion无效。工具版本 “15.0”无法识别。可用的工具版本是“2.0”,“3.5”, “4.0”。

documentation建议15.0应该是正确的。

编辑 从上What's New in MSBuild 15它指出了2017年的文件:

MSBuildToolsVersion此版本的工具是15.0。程序集版本号为012.,版本为15.1.0.0。

然而,2017年的文件MSBuild Command Line Reference状态:

对于MSBuild的4.5,您可以指定版本以下值: 2.0,3.5和4.0。如果指定4.0,则VisualStudioVersion构建属性指定要使用哪个子工具集。有关更多信息,请参阅 Toolset(ToolsVersion)的子工具集部分。

所以我有点困惑的命名:MSBuild 15或MSBuild 4.5 ...?

+1

PATH,善意的破坏者。键入“msbuild.exe”,你可能会先看到错误的列表。 –

+0

@Hans:C:\ Users \ Me>其中msbuild。EXE ** C:\ Program Files文件(x86)\ Microsoft Visual Studio \ 2017 \ BuildTools \ MSBuild \ 15.0 \ Bin \ MSBuild.exe ** – DrGriff

+0

如何直接从CMD运行构建命令行?我已经设置了这条路,并成功构建了Visual Studio 2017空白项目。您可以尝试使用Visual Studio 2017创建空白项目,然后使用上述方法在构建服务器上构建。 –

回答

0

最后解决了这个问题 - 是的,这是不正确的路径。

的解决方案是chaneg以上至powsershell行:

$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