在TFS 2013上构建失败但在本地也没问题

26 msbuild tfs nuget visual-studio-2013 tfs2013

当我签入代码时,TFS 2013自动构建了解决方案.在本地VS 2013中可以,但在TFS中失败了.

这是摘要.

Summary
FTPProcessor | Any CPU
1 error(s), 56 warning(s) 
$/xxxx/NewServiceHost/New-Branch/NewServiceHost/packageRestore.proj - 0 error(s), 0 warning(s) 
$/xxxx/NewServiceHost/New-Branch/GenericWindowsServices.sln - 1 error(s), 56 warning(s) 
C:\Builds\1\xxxx\FTP Processor (New)\src\.nuget\nuget.targets (71): The task factory "CodeTaskFactory" could not be loaded from the assembly "C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Build.Tasks.v4.0.dll". Could not load file or assembly 'file:///C:\Program Files (x86)\MSBuild\12.0\bin\amd64\Microsoft.Build.Tasks.v4.0.dll' or one of its dependencies. The system cannot find the file specified.
Other Errors 
1 error(s) 
Exception Message: MSBuild error 1 has ended this build. You can find more specific information about the cause of this error in above messages. (type BuildProcessTerminateException) Exception Stack Trace: at System.Activities.Statements.Throw.Execute(CodeActivityContext context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
Run Code Online (Sandbox Code Playgroud)

Nic*_*eus 55

您的TFS 2013构建服务器正在使用MSBuild 12.0,其中CodeTasksFactory存在于Microsoft.Build.Tasks.v12.0.dll而不是Microsoft.Build.Tasks.v4.0.dll中.

理想情况下,您应该执行以下操作:

1)打开NuGet.targets文件:C:\ Builds\1\xxxx\FTP处理器(新)\ src.nuget \nuget.targets

2)识别引用旧DLL的任务.

<UsingTask AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" TaskFactory="CodeTaskFactory" >
...
Run Code Online (Sandbox Code Playgroud)

3)然后将来证明它是这样的:

<UsingTask AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v$(MSBuildToolsVersion).dll" TaskFactory="CodeTaskFactory" >
...
Run Code Online (Sandbox Code Playgroud)

  • 我必须进行此更改并修复我的Project文件以设置ToolsVersion ="12.0"而不是4.0. (5认同)