System.Runtime.Extensions 需要更高版本的 System.Runtime

System.Runtime.Extensions requires a higher version of System.Runtime

我正在 Visual Studio 中从事那些新的 "Class Library (NuGet Package)" 项目之一。一切都很顺利,直到前几天它开始引发有关 System.Runtime.Extensions 程序集的错误:

Assembly 'System.Runtime.Extensions' with identity 'System.Runtime.Extensions,
Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' uses 'System.Runtime,
Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher
version than referenced assembly 'System.Runtime' with identity 'System.Runtime,
Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

我检查了 on NuGet 似乎确实如此,System.Runtime.Extensions 要求 System.Runtime 至少为 4.0.20。

我尝试更改 project.json"dependencies" 部分中的以下行:

"System.Runtime": "4.0.10-beta-23019",

"4.0.20-beta-23019",但它告诉我 "the type IOException exists in both System.IO and System.Runtime."

我该怎么做才能解决这个问题?

谢谢。


编辑:刚刚在一个全新的包项目上尝试了这个,它似乎也失败了,所以出了点问题。

尝试仅将其添加到 .NET Core 目标框架:

{
    "dependencies": { },

    "frameworks": {
        "dotnet": {
            "dependencies": {
                "Microsoft.CSharp": "4.0.0",
                "System.Collections": "4.0.10",
                "System.Linq": "4.0.0",
                "System.Runtime.Extensions": "4.0.10",
                "System.Threading": "4.0.10"
            }
        }
    }
}

其中 dnxcore50 是 .NET Core 目标框架。例如也可以是 dotnet

解决方案就是明确指定我对 System.Runtime.Extensions 的依赖:

"dependencies": {
    "System.Collections": "4.0.10-beta-23019",
    "System.Linq": "4.0.0-beta-23019",
    "System.Threading": "4.0.10-beta-23019",
    "System.Runtime": "4.0.10-beta-23019",
    "System.Runtime.Extensions": "4.0.0",
    "Microsoft.CSharp": "4.0.0-beta-23019"
},

所有的悲伤都是因为我想使用 Environment.NewLine。哦。