使用 TFS 2013 团队构建构建 Visual Studio C++ 解决方案 2015 失败

Building Visual Studio C++ solution 2015 failed using TFS 2013 team build

我们已将 TFS 构建机器配置为从 TFS 构建源代码。在这台机器上,我们安装了 Team Foundation Server 2013 和 Microsoft Build Tools 2013,最近,我们安装了 Microsoft Build Tools 2015。在构建定义中,我们将 /tv:14.0 用于 MSBuild 参数,以指示我们要使用 14.0 版建立。此外,我们将执行代码分析设置为 false,这样它就不会执行代码分析。 但是,当我们对构建进行排队时,它因给定错误而失败:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.targets (214): The source file for this compilation can be found at: "C:\Users\tfsservice\AppData\Local\Temp\b54ca1bb-e696-4214-a196-5c79c32345cd.txt"
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.targets (214): An error has occurred during compilation. error CS1705: Assembly 'Microsoft.Build.Utilities.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' uses 'Microsoft.Build.Framework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'Microsoft.Build.Framework, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.targets (214): The "SetEnvironmentVariable" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with <UsingTask> in the project file, or in the *.tasks files located in the "C:\Program Files (x86)\MSBuild.0\bin\amd64" directory.

以前有人遇到过这个问题吗? Microsoft.Build.Utilities.Core 似乎引用了错误版本的 Microsoft.Build.Framework。

但是,在 MSBuild.exe.config 中,此程序集被正确重定向

<dependentAssembly>
   <assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
   <bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="14.0.0.0"/>
</dependentAssembly>

感谢任何帮助。

P.s。我们要构建的方案是从VS 2013升级到VS 2015的visual c++方案。

似乎很多其他社区成员也有类似的问题,/tv:14.0 论点不起作用。检查此 以获取详细信息。

解决方法是:不使用/tv:14.0参数,而是需要自定义tfs构建过程模板来设置[=的ToolPath 24=] MSBuild for Project 目标为 MSBuild14;并将 ToolVersion 设置为“14.0”。