Aspnetcore: Failed to add reference to 'System.Runtime'. Please make sure that it is in the Global Assembly Cache.

Created on 4 Dec 2015  路  4Comments  路  Source: dotnet/aspnetcore

Not sure where to post this...

I have the following project.json using several frameworks from .NET 4, all the way up to 4.6.1 and also Serilog is added as a global dependency, while all the frameworks except .NET 4 also have Serilog.Sinks.EventLog as an additional dependency. If I remove the System.Runtime references I get 37 of these errors:

Severity Code Description Project File Line Suppression State
Error CS0012 The type 'Exception' 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'. Bridge.Logging..NET Framework 4.5, Bridge.Logging..NET Framework 4.5.1, Bridge.Logging..NET Framework 4.5.2, Bridge.Logging..NET Framework 4.6 C:\Bitbucket\Bridge.Logging\Source\Bridge.Logging\LogEventEnrichers\ExceptionEnricher.cs 52 Active

If I publish my NuGet package and then try to install it, I get the following error:

Failed to add reference to 'System.Runtime'. Please make sure that it is in the Global Assembly Cache.

Why am I being forced to add System.Runtime and what does this achieve?

My project.json

{
  ...

  "dependencies": {
    "Serilog": "1.5.14"
  },

  "frameworks": {
    "net40": {
      "frameworkAssemblies": {
        "System": "",
        "System.Core": "",
        "System.Data": "",
        "System.Runtime": ""
      }
    },
    "net45": {
      "dependencies": {
        "Serilog.Sinks.EventLog": "1.5.11"
      },
      "frameworkAssemblies": {
        "System": "",
        "System.Core": "",
        "System.Data": "",
        "System.Runtime": ""
      }
    },
    "net451": {
      "dependencies": {
        "Serilog.Sinks.EventLog": "1.5.11"
      },
      "frameworkAssemblies": {
        "System": "",
        "System.Core": "",
        "System.Data": "",
        "System.Runtime": ""
      }
    },
    "net452": {
      "dependencies": {
        "Serilog.Sinks.EventLog": "1.5.11"
      },
      "frameworkAssemblies": {
        "System": "",
        "System.Core": "",
        "System.Data": "",
        "System.Runtime": ""
      }
    },
    "net46": {
      "dependencies": {
        "Serilog.Sinks.EventLog": "1.5.11"
      },
      "frameworkAssemblies": {
        "System": "",
        "System.Core": "",
        "System.Data": "",
        "System.Runtime": ""
      }
    },
    "net461": {
      "dependencies": {
        "Serilog.Sinks.EventLog": "1.5.11"
      },
      "frameworkAssemblies": {
        "System": "",
        "System.Core": "",
        "System.Data": "",
        "System.Runtime": ""
      }
    }
  }
}

Most helpful comment

The solution was to make System.Runtime a build time dependency like so:

// Old
"System.Runtime": ""

// New
"System.Runtime": {
  "type": "build",
  "version": ""
}

I'm not entirely sure what this means so any helpful comments would be much appreciated.

All 4 comments

The solution was to make System.Runtime a build time dependency like so:

// Old
"System.Runtime": ""

// New
"System.Runtime": {
  "type": "build",
  "version": ""
}

I'm not entirely sure what this means so any helpful comments would be much appreciated.

We've also just hit this, see https://github.com/elastic/elasticsearch-net/issues/1774

Setting "type": "build" as @RehanSaeed mentioned above does seem to do the trick, but I have no idea what the implications are. Is there any documentation on this?

Also just ran intom this. Same concern as gmarz.

This issue is being closed because it has not been updated in 3 months.

We apologize if this causes any inconvenience. We ask that if you are still encountering this issue, please log a new issue with updated information and we will investigate.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ipinak picture ipinak  路  3Comments

aurokk picture aurokk  路  3Comments

FourLeafClover picture FourLeafClover  路  3Comments

snebjorn picture snebjorn  路  3Comments

UweKeim picture UweKeim  路  3Comments