.net - 在 dotnet 核心中以不同的依赖版本结束

标签 .net .net-core

我正在开展一个针对 netstandard1.6 的项目和 net451 .
不幸的是,我在构建库时收到这些警告:

C:\Path\project.json(22,35): warning NU1007: Dependency specified was Microsoft.CSharp >= 4.0.1 but ended up with Microsoft.CSharp 4.0.0.0.
C:\Path\project.json(17,38): warning NU1007: Dependency specified was System.Collections >= 4.0.11 but ended up with System.Collections 4.0.0.0.
C:\Path\project.json(18,30): warning NU1007: Dependency specified was System.Linq >= 4.1.0 but ended up with System.Linq 4.0.0.0.
C:\Path\project.json(19,33): warning NU1007: Dependency specified was System.Runtime >= 4.1.0 but ended up with System.Runtime 4.0.10.0.
C:\Path\project.json(20,49): warning NU1007: Dependency specified was System.Runtime.InteropServices >= 4.1.0 but ended up with System.Runtime.InteropServices 4.0.10.0.
C:\Path\project.json(21,36): warning NU1007: Dependency specified was System.Threading >= 4.0.11 but ended up with System.Threading 4.0.0.0.

这是我的 project.json :
{
    "version": "1.0.0-*",
    "description": "MyLibrary",

    "frameworks": {
        "net451": {
        },
        "netstandard1.6": {
        }
    },

    "dependencies": {
        "NETStandard.Library": "1.6.0",
        "Newtonsoft.Json": "9.0.1",
        "MyOtherProject.Common": "1.0.0-*",
        "System.Collections": "4.0.11",
        "System.Linq": "4.1.0",
        "System.Runtime": "4.1.0",
        "System.Runtime.InteropServices": "4.1.0",
        "System.Threading": "4.0.11",
        "Microsoft.CSharp": "4.0.1"
    }
}

库构建时没有错误定位 netstandard1.6net451 ,但是我在为 net451 构建时收到了这些警告.

有任何想法吗?

最佳答案

我有同样的问题。
我的修复,删除警告是

{
  "version": "1.0.0-*",
  "description": "MyLibrary",

  "frameworks": {
    "net451": {
      "dependencies": {
        "System.Collections": "4.0.0",
        "System.Linq": "4.0.0",
        "System.Runtime": "4.0.10",
        "System.Runtime.InteropServices": "4.0.10",
        "System.Threading": "4.0.0",
        "Microsoft.CSharp": "4.0.0"
      }
    },
    "netstandard1.6": {
      "dependencies": {
        "System.Collections": "4.0.11",
        "System.Linq": "4.1.0",
        "System.Runtime": "4.1.0",
        "System.Runtime.InteropServices": "4.1.0",
        "System.Threading": "4.0.11",
        "Microsoft.CSharp": "4.0.1"
      }
    }
  },

  "dependencies": {
    "NETStandard.Library": "1.6.0",
    "Newtonsoft.Json": "9.0.1"
  }
}

但我认为可能有一些更好的解决方案。

关于.net - 在 dotnet 核心中以不同的依赖版本结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39446243/

相关文章:

.net - 如何在 Visual Studio 2017 中从 .Net Core 控制台应用程序项目创建 EXE 输出?

.net - 我应该一般学习F#或函数式编程语言吗?

c# - 无法将字符串转换为 int。来自 XML 元素的数据。 C#

.net - Application Insights SDK SQL 依赖项跟踪不适用于 Microsoft.Data.SqlClient 2.0

c# - var 关键字运行时还是编译时?

C# 8 基本接口(interface)的默认方法调用解决方法

c# - 没有默认构造函数和自动属性,为什么它仍然可以编译

c# - 如何将 int 写入 System.Span,即 int.Parse(span) 的反面?

c# - ILoggerFactory 与 serviceCollection.AddLogging 与 WebHostBuilder.ConfigureLogging

asp.net-core - 面向 .NET Standard 的 Azure 函数显示警告