Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
RehanSaeed opened this issue Dec 4, 2015 · 4 comments

Comments

@RehanSaeed
Copy link
Contributor

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": ""
      }
    }
  }
}
@RehanSaeed RehanSaeed changed the title Referencing System.Runtime in project.json causes NuGet Install Error Failed to add reference to 'System.Runtime'. Please make sure that it is in the Global Assembly Cache. Dec 7, 2015
@RehanSaeed
Copy link
Contributor Author

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.

@gmarz
Copy link

gmarz commented Jan 29, 2016

We've also just hit this, see elastic/elasticsearch-net#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?

@RichiCoder1
Copy link

Also just ran intom this. Same concern as gmarz.

@aspnet-hello
Copy link

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.

natemcmaster pushed a commit that referenced this issue Nov 14, 2018
@ghost ghost locked as resolved and limited conversation to collaborators Dec 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants