Search code examples
c#asp.net-mvcportable-class-library

Build error: You must add a reference to System.Runtime


I'm preparing a brand new ASP.NET MVC 5.1 solution. I'm adding in a bunch of NuGet packages and setting it up with Zurb Foundation, etc.

As part of that, I've added a reference to an in-house NuGet package which is a Portable Class Library and I think this is causing a problem on the build server.

TeamCity fails the build with:

The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0

I originally added the fix for the same or similar error when compiling the Razor web pages, that fix being in the web.config

<compilation ... >
  <assemblies>
    <add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  </assemblies>
</compilation>

However, the issue is unresolved.


Solution

  • Adding a reference to this System.Runtime.dll assembly fixed the issue:

    C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Facades\System.Runtime.dll
    

    Though that file in that explicit path doesn't exist on the build server.

    I will post back with more information once I've found some documentation on PCL and these Facades.

    Update

    Yeah pretty much nothing on facade assemblies on the whole internet.

    Google:

    (Facades OR Facade) Portable Library site:microsoft.com