如何在通用 Windows 平台应用程序中更新一个特定的 .NET 程序集?

4

我了解到,.NET已经开源,并且通过精细的NuGet包分发,而不是像过去一样的整体安装程序。

我创建了一个简单的UWP应用程序,我在项目的json文件中看到的是:

{
  "dependencies": {
    "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0"
  },
  "frameworks": {
    "uap10.0": {}
  },
  "runtimes": {
    "win10-arm": {},
    "win10-arm-aot": {},
    "win10-x86": {},
    "win10-x86-aot": {},
    "win10-x64": {},
    "win10-x64-aot": {}
  }
}

当我尝试通过Nuget安装预发版System.Collections时,我遇到了以下问题:

Version conflict detected for System.Private.Uri. 
 SM.W10 (≥ 1.0.0) -> System.Collections (≥ 4.0.11-beta-23516) -> System.Runtime (≥ 4.0.21-beta-23516) -> System.Private.Uri (≥ 4.0.1-beta-23516) 
 SM.W10 (≥ 1.0.0) -> Microsoft.NETCore.UniversalWindowsPlatform (≥ 5.0.0) -> Microsoft.NETCore.Runtime (≥ 1.0.0) -> Microsoft.NETCore.Runtime.CoreCLR-arm (≥ 1.0.0) -> System.Private.Uri (= 4.0.0).

我觉得我应该以某种方式解开 Microsoft.NETCore.UniversalWindowsPlatform,但它有许多层嵌套,只有深度嵌套的 Microsoft.NETCore.Runtime.CoreCLR-arm 有 System.Private.Url 的严格版本。

有没有什么方法可以无痛更新 System.Collections?


我认为你可以在依赖项下添加一个条目,指向你想要的 System.Collection 发布版。只需将它放在 .NetCore 条目下面即可。 - JWP
1个回答

6

在首次发布时,UWP应用程序会固定所有核心包,因为这些包之间存在一些私有依赖关系,例如System.RuntimeSystem.Collections和.NETNative工具链。因此,如果要测试任何最低级别合同的新版本,您还需要更新运行时包。

例如:

"dependencies": {
  "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0"
  "Microsoft.NETCore.Runtime": "1.0.1-beta-23516",
  "System.Collections" :  "4.0.11-beta-23516"
}

只有在我们堆栈的最底部的软件包中,特别是这种行为才会出现。

System.Collections,
System.Diagnostics.Contracts,
System.Diagnostics.Debug,
System.Diagnostics.StackTrace,
System.Diagnostics.Tools,
System.Diagnostics.Tracing,
System.Globalization,
System.Globalization.Calendars,
System.IO,
System.ObjectModel,
System.Reflection,
System.Reflection.Extensions,
System.Reflection.Primitives,
System.Resources.ResourceManager,
System.Runtime,
System.Runtime.Extensions,
System.Runtime.Handles,
System.Runtime.InteropServices,
System.Text.Encoding,
System.Text.Encoding.Extensions,
System.Threading,
System.Threading.Tasks,
System.Threading.Timer

未来的UWP版本将不会出现这个问题。我们发现使用NuGet来强制执行私有依赖关系是脆弱的,并且会产生混淆的错误。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接