简体   繁体   中英

How to reference a specific version of NetStandard in project.json?

I am struggling to figure out how to force the npm ( Nuget Package Manager ) to resolve a specific version of the NetStandard1.X platform.

I am trying to use Serilog but the version of .NetStandard it supports is v1.3. Is there any way to force this behavior in the project.json file via some command or switch or option.

        {
  "version": "1.0.0-*",

  "dependencies": {
    "NETStandard.Library": "1.6.0",
    "Serilog": "2.2.1"
  },

  "frameworks": {
    "netstandard1.3": {
      "imports": "dnxcore50",
      "dependencies": {
      }
    }
  }
}

When you specify v1.3 , you end up with v1.6 . Surely there must be a way of doing this? I am trying to upgrade an old .net framework 4.6 class library that was using log4net and I am struggling with the basics here.

Error Dump:

Package Serilog 2.2.1 is not compatible with netstandard1.6 (.NETStandard,Version=v1.6). Package Serilog 2.2.1 supports:
  - net45 (.NETFramework,Version=v4.5)
  - net46 (.NETFramework,Version=v4.6)
  - netstandard1.0 (.NETStandard,Version=v1.0)
  - netstandard1.3 (.NETStandard,Version=v1.3)
One or more packages are incompatible with .NETStandard,Version=v1.6.

DotNet Core Version Info:

Product Information:

Version: 1.0.0-preview2-003131

Commit SHA-1 hash: 635cf40e58

Your project.json restores on my machine correctly, so I would guess there is something wrong with packages/versioning.

Please try to change Serilog dependency version:

"Serilog": "2.3.0-dev-00711"

Or as you suggested yourself during our chat, move the decency into framework tag:

"frameworks": { 
    "netstandard1.6": { 
        "imports": "dotnet5.6", 
        "dependencies": { 
            "Serilog": "2.3.0-dev-00711" 
        } 
    } 
} 

I'm not quite sure I understand what the question is or what exactly is the problem you're having.

But one thing that jumps at me about your project.json is that the version of NETStandard.Library should be 1.6.0 , even if you're targeting netstandard1.3 . (Yes, it's confusing.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM