【问题标题】:Nuget installs System.Console as dependency for my UWP libraryNuget 安装 System.Console 作为我的 UWP 库的依赖项
【发布时间】:2017-07-09 22:41:00
【问题描述】:

我为 UWP 应用创建了一个库。 project.json 是这样的:

{
  "dependencies": {
    "System.Collections.NonGeneric": "4.0.1-*",
    "System.Collections.Specialized": "4.0.1-*",
    "System.Net.Requests": "4.0.11-*",
    "System.Net.Security": "4.0.0-*",
    "System.Security.Cryptography.Algorithms": "4.2.0-*",
    "System.Security.Cryptography.Pkcs": "4.0.0-*",
    "System.Globalization.Extensions": "4.0.1-*"
  },
  "frameworks": {
    "uap10.0": {
      "dependencies": {
        "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2-*",
        "System.Runtime.InteropServices.RuntimeInformation": "4.0.0-*"
      }
    },
    "netstandard1.3": {
      "dependencies": {
        "NETStandard.Library": "1.6.0-*",
        "System.Xml.XmlDocument": "4.0.1-*",
        "System.Net.NetworkInformation": "4.1.0-*",
        "System.Net.NameResolution": "4.0.0-*",
        "Microsoft.Win32.Registry": "4.0.0-*",
        "System.Threading.Thread": "4.0.0-*"
      }
    }
  }
}

我创建了一个 nuget 包,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
  <metadata>
    <id>...</id>
    <version>...</version>
    <title>...</title>
    <authors>...</authors>
    <owners>...</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <licenseUrl>...</licenseUrl>
    <projectUrl>...</projectUrl>
    <iconUrl?...</iconUrl>
    <description>...</description>
    <summary>...</summary>
    <releaseNotes>...</releaseNotes>
    <copyright>...</copyright>
    <tags>...</tags>
    <dependencies>
      <group targetFramework=".NETStandard1.3">
        <dependency id="NETStandard.Library" version="1.6.0" />
      </group>
    </dependencies>
  </metadata>
</package>

即还没有 UWP lib 的依赖信息。

但是,在安装这个包时,nuget 会提示我安装 System.Console 包。

我很确定我从来没有在我的库中访问过控制台,也没有 Dependency Walker 看到任何对它的引用。为什么会发生这种情况?是否有可能来自 project.json 依赖项的其他一些库间接依赖于它?我在 Dependency Walker 中浏览了引用的库的依赖项,但在第一级找不到任何东西(依赖关系树非常深入地手动查找每个依赖项)。

如何识别导致 System.Console 依赖出现的引用?它还好吗?我的印象是 Console 和 UWP 不能很好地配合。

Nuget 3.5、Visual Studio 2015 更新 3。

【问题讨论】:

    标签: visual-studio-2015 uwp nuget


    【解决方案1】:

    您的 nuget 包中有 NETStandard.Library 的依赖项,版本为 1.6.0。然后您可以在 Package Manager UI 或NuGet.org 中检查 NETStandard.Library 1.6.0 的依赖项,找出 NETStandard.Library 引用的依赖项 System.Console (>= 4.0.0):

    安装NuGet包UniApp后就完全没问题了。下面是我成功安装该软件包后的 project.json 文件。

    【讨论】:

      猜你喜欢
      • 2018-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-19
      相关资源
      最近更新 更多