7
votes

I have an ASP.NET web application targeting .NET 4.5. Locally, the project builds, but on the build server (TeamCity) it fails:

...cs(77, 38): error CS0012: The type 'System.Enum' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

What can be the cause of (and remedy for) this?

2
The remedy seems obvious: adding the reference. If you tried that, why didn't it work for you?Patrick Hofman
How is your build agent configured?Tieson T.
If I try to add a reference using the "framework" option targeting .NET 4.5, I do not find a "System.Runtime" in the list. Furthermore, I would like to know why this builds locally, and the application runs, while not building on the particular build server. I am also reluctant to add a reference to something just for the purpose of building if I do not know the cause.Vidar Kongsli
As for why something builds locally vs. on the server? It's all about what's in the GAC (global assembly cache). Are you including any packages or plugins that were built for an earlier framework version?Tieson T.

2 Answers

7
votes

I had the very same error message (although targeting framework 4.5.1). The answer for me was to install the Microsoft .NET Framework 4.5.1 Developer Pack on the build server.

If targeting framework 4.5 and the build server is running Windows Server 2012, be sure to add the .NET Framework 4.5. Features using Server Manager. If TeamCity is installed on a previous version of Windows, check out the Microsoft .NET Framework installation guide.

2
votes

The problem was that Team City was set up to use "Visual Studio 2013" in the build step, while our project uses "Visual Studio 2012".