2017-02-20 47 views
0

我为UWP应用程序创建了一个库。 project.json是这样的:Nuget安装System.Console作为我的UWP库的依赖关系

{ 
    "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软件包。

enter image description here

我敢肯定,我从来没有在我的图书馆访问控制台,既不Dependency Walker中看到它的任何引用。为何会发生这种情况? project.json依赖项中的其他库是否可能间接依赖它?我在Dependency Walker中引用了引用的libs的依赖关系,但在第一级找不到任何东西(依赖关系树非常深入地手动查找每个依赖关系)。

如何确定哪些引用会导致System.Console依赖项出现?它可以吗?我的印象是控制台和UWP不太好。

的NuGet 3.5时,Visual Studio 2015年更新3

回答

1

你NETStandard.Library与您的NuGet包版本1.6.0的相关性。然后,你可以检查包管理器UI或NuGet.org的NETStandard.Library 1.6.0的依赖关系,找出依赖System.Console(> = 4.0.0)由NETStandard.Library引用:

enter image description here

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

enter image description here