ilivewithian
ilivewithian

Reputation: 19712

.Net 4.5.1 on Team City

I am trying to build a .Net 4.5.1 web project on a team city server. I have installed the windows 8.1 SDK which, which seems to have the assembly Microsoft.Build.Tasks.v4.0.dll in it. However, when I'm trying to build the project I still get the error:

C:\TeamCity\buildAgent\work\bdb0a42dd3d7277\.nuget\NuGet.targets(71, 9): error MSB4175: The task factory "CodeTaskFactory" could not be loaded from the assembly "C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Build.Tasks.v4.0.dll". Could not load file or assembly 'file:///C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Build.Tasks.v4.0.dll' or one of its dependencies. The system cannot find the file specified.

What do I need to install on the build server or copy from my build environment?

UPDATE

The question is still open, but for now I have solved the issue by editing the project files to use MSBuild 4.0, rather than 12.

Upvotes: 3

Views: 11623

Answers (6)

PARUS
PARUS

Reputation: 113

Change " to in csproj file. That's all need to do.

Upvotes: -2

faester
faester

Reputation: 15086

You can solve this problem by installing Microsoft Build Tools 2013. After the installation has completed (and possible a restart of TeamCity Server) you should have Microsoft Build Tools 2013 available as an option under MSBuild version for all "MSBuild" type steps in TeamCity. Select this and everything should be fine and dandy.

I would prefer this to installing VS on the build server since it leaves a substantially smaller footprint on the server.

Upvotes: 2

Barry
Barry

Reputation: 606

I had a problem similar to this when using the msbuild task via rake: http://www.beta.microsoft.com/VisualStudio/feedback/details/806393/error-trying-to-build-using-msbuild-from-code

Hello and thank you for the feedback. I believe you are running into this issue as a side-effect of MSBuild moving out of the .NET Framework (more info here: http://blogs.msdn.com/b/visualstudio/archive/2013/07/24/msbuild-is-now-part-of-visual-studio.aspx).

Your project is referencing the older version of MSBuild that is still in the .NET Framework. This version was used until Visual Studio 2013. Since you are debugging the project from Visual Studio 2013, the VisualStudioVersion environment variable is automatically set to “12.0”. This is causing the 2013 code analysis targets to be loaded with the project, but these targets are not compatible with the old version of MSBuild because VS 2013 uses MSBuild 12.0 exclusively.

Upvotes: 3

Ilia Barahovsky
Ilia Barahovsky

Reputation: 10498

I'm not sure what the problem is, but we always install Visual Studio on computers running Team City agents. Usually it solves all relevant dependencies, including MSBuild, .NET, build targets etc.

For .NET 4.5.1 it would be Visual Studio 2013.

Another advice - Team City added support for VS 2013 and relevant build tools only in TC 8.1 - http://confluence.jetbrains.com/display/TW/Gaya+8.1+EAP1+%28build+29353%29+Release+Notes#Gaya8.1EAP1%28build29353%29ReleaseNotes-MSVisualStudio2013supportinbuildrunners. Probably upgrade to the latest TC may help.

Upvotes: 0

jaminto
jaminto

Reputation: 3955

I don't know who's at fault here, but either msbuild or team city have things backwards.

The two files involved are:

C:\Program Files (x86)\MSBuild\12.0\Bin\Microsoft.Build.Tasks.v12.0.dll C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Build.Tasks.v4.0.dll

If the team city error message wants the Microsoft.Build.Tasks.v4.0.dll in the C:\Program Files (x86)\MSBuild\12.0\bin\ folder, then copy it there from C:\Windows\Microsoft.NET\Framework\v4.0.30319\. Or if it wants the Microsoft.Build.Tasks.v12.0.dll in the C:\Windows\Microsoft.NET\Framework\v4.0.30319\ folder, then copy it from from the C:\Program Files (x86)\MSBuild\12.0\Bin\ folder.

For me, the magic combo was:

  • MSBuild Version : Microsoft .NET Framework 4.5
  • MSBuildTools Version : 4.0

and i copied the Microsoft.Build.Tasks.v12.0.dll to C:\Windows\Microsoft.NET\Framework\v4.0.30319\

Upvotes: 1

Matt
Matt

Reputation: 1374

Double check your tools and target .Net framework in the msbuild step in TeamCity and make sure they are set to V4.0 and .Net framework 4.5. Also make sure your version of NuGet.exe that is in the .nuget directory is at least version 2.7.0. After I corrected these two things this error went away.

Upvotes: 0

Related Questions