TFS Build 未找到框架“.NETFramework,Version=v4.6”的参考程序集

TFS Build The reference assemblies for framework ".NETFramework,Version=v4.6" were not found

安装了 .NET 4.6 的 TFS 2012 构建服务器在尝试构建针对 .NET 4.6 的网站时产生以下错误消息。

安装后机器已经重启。

我是否需要以某种方式告诉 TFS 支持 .NET 4.6?

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets (983): The reference assemblies for framework ".NETFramework,Version=v4.6" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

首先,您需要确保可以在TFS 生成服务器上找到项目中所有引用的程序集。为了获得最佳实践,您需要在构建服务器计算机上安装 VS2015

其次,您需要自定义 TFS 构建过程模板以在 运行 MSBuild for Project[=17] 中显式设置 ToolPath 变量=] activity 为 C:\Program Files (x86)\MSBuild.0\Bin。或者将 /tv:14.0 参数添加到 MSBuild 命令。

我在构建服务器上安装了 .NET Framework 4.6 Targeting Pack 并为我解决了它。