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

UWP application and .NET Core RC2: cannot reference netstandard1.4 packages

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

使用 "generate build output" 我可以从 .NET Core 应用程序(控制台)引用创建的 nuget 包并使用解决方法(从 %local%.dnx -> %local%.nuget 复制包) UWP 应用程序也能够引用和使用该包。

现在在 RC2 中情况发生了一些变化,我再次能够使用升级后的库(项目文件中升级的工具,更改为 project.json,netstandard1.4(因为 1.5 不适用于 UAP10,根据this)) 完美使用 .NET Core 控制台应用程序。

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

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

错误。

环顾四周后,我试图找出问题并发现我什至无法添加对 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).

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

除了 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 团队