10

I created a new .NET Core Class Library and added a Nuget package from an internal company Nuget server. I began getting the following error:

Package XXXX is not compatible with netstandard1.5 (.NETStandard,Version=v1.5). Package XXXX 1.0 supports: net45 (.NETFramework,Version=v4.5) One or more packages are incompatible with .NETStandard,Version=v1.5.

I updated the project.json file to look like this but the same error persists.

{
  "version": "1.0.0-*",

  "dependencies": {
    "XXXXX": "1.0.0",
    "NETStandard.Library": "1.5.0-rc2-24027"
  },

  "frameworks": {
    "netstandard1.5": {
      "imports": [
        "dnxcore50",
        "portable-net45+win8"
      ]
    }
  }
}

Does anyone have insight on this?

Nate Barbettini
  • 51,256
  • 26
  • 134
  • 147
Tyson Nero
  • 2,048
  • 5
  • 26
  • 36
  • 1
    @HansPassant To my understanding, the .NET Platform Standard is done now. There will be additive changes in the future, but not breaking ones. – Nate Barbettini Jun 09 '16 at 15:07

1 Answers1

11

Tl;dr - it has to be netstandard all the way down!

To install a package in a .NET Core project, the package and all of its dependencies must be compatible with netstandard1.X.

It looks like your project targets netstandard1.5, but depends on a package that only targets net45. The only way to resolve this is to replace the dependency, or update it to a version that targets netstandard.

In some cases, imports will allow you to use a Portable Class Library in a .NET Core application. This isn't a general cure-all for incompatible packages, but rather a temporary fix that works with packages that already target a smaller API.

Community
  • 1
  • 1
Nate Barbettini
  • 51,256
  • 26
  • 134
  • 147
  • 1
    I've seen a couple references that say including "portable-net4+win8" with net4 being the framework version will fix this issue. E.g. https://docs.efproject.net/en/latest/miscellaneous/rc1-rc2-upgrade.html#using-imports-in-project-json. – Tyson Nero Jun 08 '16 at 20:43
  • 1
    @GrandMasterT Does importing `portable-net45+netcore45+wp8` work for you? – Nate Barbettini Jun 08 '16 at 20:52
  • 2
    @GrandMasterT That can work only if the package is a Portable Class Library. It doesn't seem your package is that. – svick Jun 08 '16 at 21:15
  • @NateBarbettini No, importing is not working in my case. I know that it does work with several other Nuget packages or libraries. EF and xUnit are just two examples. – Tyson Nero Jun 09 '16 at 12:30