neleus
neleus

Reputation: 2280

project.json dependencies targeting different versions of NETStandard.Library

I have a class library where project.json file looks as follows:

{
  "version": "1.0.0-*",

  "dependencies": {
    "NETStandard.Library": "1.6.0",
    "System.Security.Claims": "4.0.1"
  },

  "frameworks": {
    "netstandard1.2": {
      "imports": "dnxcore50"
    }
  }
}

It targets netstandard1.2 and at the same time uses System.Security.Claims.4.0.1 which depends on netstandard1.3. And also it uses NETStandard.Library.1.6.0. This means that I can use any classes/methods which don't exist in netstandard1.2. But at the same time my project compiles well regardless of it.

Why doesn't it throw error? It looks like the compiler doesn't validate platforms listed in "frameworks" section against global dependencies, right? But what is the reason?

Upvotes: 2

Views: 257

Answers (1)

k94ll13nn3
k94ll13nn3

Reputation: 679

This line "imports": "dnxcore50" is the reason why it works. If you delete it, you will have a Package System.Security.Claims 4.0.1 is not compatible with netstandard1.2 (.NETStandard,Version=v1.2)..

And for "NETStandard.Library": "1.6.0",, only dependencies with netstandard1.2 and less will be referenced, so you won't be able to use any classes/methods which don't exist in netstandard1.2 (the 1.6.0 does not link to netstandard1.6)

Upvotes: 2

Related Questions