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

岁酱吖の 提交于 2020-01-07 03:44:28

问题


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


回答1:


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" 
        } 
    } 
} 



回答2:


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.)



来源:https://stackoverflow.com/questions/39817579/how-to-reference-a-specific-version-of-netstandard-in-project-json

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!