【问题标题】:Xamarin Forms UWP failing to reference NuGet package System referencesXamarin Forms UWP 无法引用 NuGet 包系统引用
【发布时间】:2017-09-22 04:32:12
【问题描述】:

我正在尝试将使用 Visual Studio 2017 自动构建的自制 NuGet 包添加到 UWP Xamarin Forms 项目中。

但是,当我尝试将包添加到 UWP 包(在 VS2017 包管理器中)时,它失败了。

Restoring packages for C:\Development\MyMobile\JobApp\JobApp\JobApp.UWP\project.json...
System.Threading.ThreadPool 4.3.0 provides a compile-time reference assembly for System.Threading.ThreadPool on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-arm.
System.Threading.Thread 4.3.0 provides a compile-time reference assembly for System.Threading.Thread on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-arm.
System.Diagnostics.Process 4.3.0 provides a compile-time reference assembly for System.Diagnostics.Process on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-arm.
One or more packages are incompatible with UAP,Version=v10.0 (win10-arm).
System.Threading.ThreadPool 4.3.0 provides a compile-time reference assembly for System.Threading.ThreadPool on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-arm-aot.
System.Threading.Thread 4.3.0 provides a compile-time reference assembly for System.Threading.Thread on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-arm-aot.
System.Diagnostics.Process 4.3.0 provides a compile-time reference assembly for System.Diagnostics.Process on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-arm-aot.
One or more packages are incompatible with UAP,Version=v10.0 (win10-arm-aot).
System.Threading.ThreadPool 4.3.0 provides a compile-time reference assembly for System.Threading.ThreadPool on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x64.
System.Threading.Thread 4.3.0 provides a compile-time reference assembly for System.Threading.Thread on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x64.
System.Diagnostics.Process 4.3.0 provides a compile-time reference assembly for System.Diagnostics.Process on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x64.
One or more packages are incompatible with UAP,Version=v10.0 (win10-x64).
System.Threading.ThreadPool 4.3.0 provides a compile-time reference assembly for System.Threading.ThreadPool on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x64-aot.
System.Threading.Thread 4.3.0 provides a compile-time reference assembly for System.Threading.Thread on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x64-aot.
System.Diagnostics.Process 4.3.0 provides a compile-time reference assembly for System.Diagnostics.Process on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x64-aot.
One or more packages are incompatible with UAP,Version=v10.0 (win10-x64-aot).
System.Threading.ThreadPool 4.3.0 provides a compile-time reference assembly for System.Threading.ThreadPool on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x86.
System.Threading.Thread 4.3.0 provides a compile-time reference assembly for System.Threading.Thread on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x86.
System.Diagnostics.Process 4.3.0 provides a compile-time reference assembly for System.Diagnostics.Process on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x86.
One or more packages are incompatible with UAP,Version=v10.0 (win10-x86).
System.Threading.ThreadPool 4.3.0 provides a compile-time reference assembly for System.Threading.ThreadPool on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x86-aot.
System.Threading.Thread 4.3.0 provides a compile-time reference assembly for System.Threading.Thread on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x86-aot.
System.Diagnostics.Process 4.3.0 provides a compile-time reference assembly for System.Diagnostics.Process on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-x86-aot.
One or more packages are incompatible with UAP,Version=v10.0 (win10-x86-aot).
Package restore failed. Rolling back package changes for 'JobApp.UWP'.
Time Elapsed: 00:00:02.8217814
========== Finished ==========

我为 UWP 项目编辑了 project.json 以尝试添加 netstandard1.6 和 System.* 依赖项,但遗憾的是没有工作。

{
  "dependencies": {
    "Microsoft.NETCore.UniversalWindowsPlatform": "5.3.3",
    "MvvmLight": "5.3.0",
    "Newtonsoft.Json": "10.0.2",
    "Xamarin.Forms": "2.3.4.231",
    "System.Threading": "4.3.0",
    "System.Runtime": "4.3.0",
    "System.Diagnostics.Process": "4.3.0",
    "System.Threading.Thread": "4.3.0",
    "System.Threading.ThreadPool": "4.3.0"
  },
  "frameworks": {
    "uap10.0": {
      "imports": "netstandard1.6"
    }
  },
  "runtimes": {
    "win10-arm": {},
    "win10-arm-aot": {},
    "win10-x86": {},
    "win10-x86-aot": {},
    "win10-x64": {},
    "win10-x64-aot": {}
  }
}

为什么 UWP 在 System.* 引用方面存在问题?

这是我的包的 NuSpec;

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
    <metadata>
        <id>MyCommon</id>
        <version>1.0.131</version>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <dependencies>
            <group targetFramework=".NETFramework4.6">
                <dependency id="Quartz" version="3.0.0-alpha2" exclude="Build,Analyzers" />
                <dependency id="ImageSharp" version="1.0.0-alpha5-00046" exclude="Build,Analyzers" />
                <dependency id="System.ComponentModel" version="4.3.0" exclude="Build,Analyzers" />
            </group>
            <group targetFramework=".NETStandard1.6">
                <dependency id="Quartz" version="3.0.0-alpha2" exclude="Build,Analyzers" />
                <dependency id="NETStandard.Library" version="1.6.1" exclude="Build,Analyzers" />
                <dependency id="ImageSharp" version="1.0.0-alpha5-00046" exclude="Build,Analyzers" />
                <dependency id="System.ComponentModel" version="4.3.0" exclude="Build,Analyzers" />
            </group>
        </dependencies>
    </metadata>
</package>

【问题讨论】:

  • 你能提供.nuspec文件吗?
  • 修改了我的问题,谢谢

标签: uwp xamarin.forms nuget-package visual-studio-2017


【解决方案1】:

您的 NuGet 包引用了Quartz 3.0.0-alpha2,它引用了System.Threading.ThreadSystem.Threading.ThreadPool

通用 Windows 平台不支持这两个包(System.Threading.ThreadSystem.Threading.ThreadPool),至少目前不支持。

Here,Immo Landwerth(.NET 团队的项目经理)说:

  • UWP 目前仅支持 .NET Standard 1.4
  • 我们的目标是 最终扩展 UWP 以实现 .NET Standard 2.0。一旦那个 碰巧,UWP 也会支持Thread

以下是一些 GitHub 问题,您可以在其中阅读有关此主题的更多信息:

【讨论】:

  • 非常有用,谢谢! UWP 不支持 .NET Standard 1.6 令人沮丧,这意味着我们的 Windows Mobile 支持将被延迟。
猜你喜欢
  • 2019-09-07
  • 2016-08-03
  • 2019-01-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多