简体   繁体   English

如何在project.json中引用特定版本的NetStandard?

[英]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. 我正在努力找出如何强制npm( Nuget软件包管理器 )解析NetStandard1.X平台的特定版本。

I am trying to use Serilog but the version of .NetStandard it supports is v1.3. 我正在尝试使用Serilog,但它支持的.NetStandard版本是v1.3。 Is there any way to force this behavior in the project.json file via some command or switch or option. 有什么方法可以通过某些命令或开关或选项在project.json文件中强制这种行为。

        {
  "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 . 当您指定v1.3时 ,最终将得到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. 我正在尝试升级使用log4net的旧.net框架4.6类库,而我在这里苦苦挣扎。

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: DotNet核心版本信息:

Product Information: 产品信息:

Version: 1.0.0-preview2-003131 版本:1.0.0-preview2-003131

Commit SHA-1 hash: 635cf40e58 提交SHA-1哈希值:635cf40e58

Your project.json restores on my machine correctly, so I would guess there is something wrong with packages/versioning. 您的project.json在我的机器上正确还原,因此我猜想软件包/版本有问题。

Please try to change Serilog dependency version: 请尝试更改Serilog依赖版本:

"Serilog": "2.3.0-dev-00711"

Or as you suggested yourself during our chat, move the decency into framework tag: 或者,如您在我们的聊天中建议的那样,将礼仪移入framework标签:

"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 . 但是关于project.json的让我NETStandard.Library是,即使您的目标是netstandard1.3NETStandard.Library的版本NETStandard.Library应该是1.6.0 (Yes, it's confusing.) (是的,这很令人困惑。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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