UWP 应用程序和 .NET Core RC2:无法引用 netstandard1.4 包

2024-02-27

我有一个场景,我使用共享代码库运行 UWP 客户端应用程序、UWP IOT 应用程序和 .NET Core 应用程序。 在 .NET Core RC1 中,我构建了一个类库(包)并使用“dotnet5.4”作为该库的基础框架。

使用“生成构建输出”,我可以引用从 .NET Core 应用程序(控制台)创建的 nuget 包,并使用解决方法(从 %local%.dnx -> %local%.nuget 复制包),UWP 应用程序能够也参考并使用该包。

现在在 RC2 中,情况发生了一些变化,我再次能够使用升级后的库(项目文件中升级的工具、对project.json、netstandard1.4 的更改(因为根据 1.5 不适用于 UAP10)this https://github.com/dotnet/corefx/blob/master/Documentation/architecture/net-platform-standard.md)) 完美地使用 .NET Core 控制台应用程序。

对于 UWP,我无法添加库,因为我收到了数十个臭名昭著的库

"[...] provides a compile-time reference assembly [...] but there is no run-time assembly compatible with [...]"

errors.

经过一番查看后,我尝试隔离问题,发现我什至无法添加对 System.IO.FileSystem.Watcher 的引用,因为:

System.IO.FileSystem.Watcher 4.0.0-rc2-24027 provides a compile-time reference assembly for System.IO.FileSystem.Watcher on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-arm-aot.
Some packages are not compatible with UAP,Version=v10.0 (win10-x64-aot).
System.IO.FileSystem.Watcher 4.0.0-rc2-24027 provides a compile-time reference assembly for System.IO.FileSystem.Watcher on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x64.
Some packages are not compatible with UAP,Version=v10.0 (win10-arm).
Some packages are not compatible with UAP,Version=v10.0 (win10-x86-aot).
System.IO.FileSystem.Watcher 4.0.0-rc2-24027 provides a compile-time reference assembly for System.IO.FileSystem.Watcher on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x86.
System.IO.FileSystem.Watcher 4.0.0-rc2-24027 provides a compile-time reference assembly for System.IO.FileSystem.Watcher on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x86-aot.
System.IO.FileSystem.Watcher 4.0.0-rc2-24027 provides a compile-time reference assembly for System.IO.FileSystem.Watcher on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-arm.
Some packages are not compatible with UAP,Version=v10.0 (win10-x64).
System.IO.FileSystem.Watcher 4.0.0-rc2-24027 provides a compile-time reference assembly for System.IO.FileSystem.Watcher on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x64-aot.
Some packages are not compatible with UAP,Version=v10.0 (win10-x86).
Some packages are not compatible with UAP,Version=v10.0 (win10-arm-aot).

我有一个最小的解决方案来重现上传的问题.

除了 project.json 中的依赖项之外,我没有对空白 UWP 模板进行任何更改:

"dependencies":
{
    "Microsoft.ApplicationInsights": "2.1.0-beta4",
    "Microsoft.ApplicationInsights.PersistenceChannel": "2.0.0-beta3",
    "Microsoft.ApplicationInsights.WindowsApps": "1.1.1",
    "Microsoft.NETCore.Platforms": "1.0.1-rc2-24027",
    "Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0",
    "NETStandard.Library": "1.5.0-rc2-24027",

    "System.IO.FileSystem.Watcher": "4.0.0-rc2-24027"
},

注意:我将 Microsoft.NETCore.UniversalWindowsPlatform 更新到最新版本。我添加了 NETStandard.Library 和 Microsoft.NETCore.Platforms。

非常感谢帮助! 提前致谢 -西蒙


UWP 目前不支持 System.IO.FileSystem.Watcher。现代 SDK 没有公开我们需要实现它的底层 Windows API (ReadDirectoryChanges)。

-Eric,.NET 团队

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

UWP 应用程序和 .NET Core RC2:无法引用 netstandard1.4 包 的相关文章

随机推荐