Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CS0012 System.enum is defined in an assembly not referenced on build server targeting .NET 4.5

Tags:

c#

.net

asp.net

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?

like image 527
Vidar Kongsli Avatar asked Jun 17 '14 06:06

Vidar Kongsli


1 Answers

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.

like image 177
Mattias Larsson Avatar answered Sep 24 '22 01:09

Mattias Larsson