为什么NuGet下载看似不必要的依赖?

时间:2016-03-09 17:33:38

标签: c# nuget

安装System.Collections.Immutable NuGet下载System.Runtime等程序集时,即使我已经安装了.NET 4.6.1的程序集。

此外, lib 下的目录(如packages \ System.Runtime.4.0.0 \ lib \ net45)不包含dll文件,只包含名为_._的空文件。

为什么会这样?为什么这有必要?我在这里缺少什么?

NuGet日志:

Install-Package System.Collections.Immutable -Version 1.1.37
Attempting to gather dependency information for package 'System.Collections.Immutable.1.1.37' with respect to project 'ConsoleApplication1', targeting '.NETFramework,Version=v4.6.1'
Attempting to resolve dependencies for package 'System.Collections.Immutable.1.1.37' with DependencyBehavior 'Lowest'
Resolving actions to install package 'System.Collections.Immutable.1.1.37'
Resolved actions to install package 'System.Collections.Immutable.1.1.37'
  GET https://www.nuget.org/api/v2/package/System.Collections/4.0.0
Installing System.Collections 4.0.0.
Adding package 'System.Collections.4.0.0' to folder 'd:\workspace\ConsoleApplication1\packages'
Added package 'System.Collections.4.0.0' to folder 'd:\workspace\ConsoleApplication1\packages'
Added package 'System.Collections.4.0.0' to 'packages.config'
Successfully installed 'System.Collections 4.0.0' to ConsoleApplication1
  GET https://www.nuget.org/api/v2/package/System.Diagnostics.Debug/4.0.0
Installing System.Diagnostics.Debug 4.0.0.
Adding package 'System.Diagnostics.Debug.4.0.0' to folder 'd:\workspace\ConsoleApplication1\packages'
Added package 'System.Diagnostics.Debug.4.0.0' to folder 'd:\workspace\ConsoleApplication1\packages'
Added package 'System.Diagnostics.Debug.4.0.0' to 'packages.config'
Successfully installed 'System.Diagnostics.Debug 4.0.0' to ConsoleApplication1
  GET https://www.nuget.org/api/v2/package/System.Globalization/4.0.0
Installing System.Globalization 4.0.0.
Adding package 'System.Globalization.4.0.0' to folder 'd:\workspace\ConsoleApplication1\packages'
Added package 'System.Globalization.4.0.0' to folder 'd:\workspace\ConsoleApplication1\packages'
Added package 'System.Globalization.4.0.0' to 'packages.config'
Successfully installed 'System.Globalization 4.0.0' to ConsoleApplication1
  GET https://www.nuget.org/api/v2/package/System.Linq/4.0.0
Installing System.Linq 4.0.0.
Adding package 'System.Linq.4.0.0' to folder 'd:\workspace\ConsoleApplication1\packages'
Added package 'System.Linq.4.0.0' to folder 'd:\workspace\ConsoleApplication1\packages'
Added package 'System.Linq.4.0.0' to 'packages.config'
Successfully installed 'System.Linq 4.0.0' to ConsoleApplication1
  GET https://www.nuget.org/api/v2/package/System.Resources.ResourceManager/4.0.0
Installing System.Resources.ResourceManager 4.0.0.
Adding package 'System.Resources.ResourceManager.4.0.0' to folder 'd:\workspace\ConsoleApplication1\packages'
Added package 'System.Resources.ResourceManager.4.0.0' to folder 'd:\workspace\ConsoleApplication1\packages'
Added package 'System.Resources.ResourceManager.4.0.0' to 'packages.config'
Successfully installed 'System.Resources.ResourceManager 4.0.0' to ConsoleApplication1
  GET https://www.nuget.org/api/v2/package/System.Runtime/4.0.0
Installing System.Runtime 4.0.0.
Adding package 'System.Runtime.4.0.0' to folder 'd:\workspace\ConsoleApplication1\packages'
Added package 'System.Runtime.4.0.0' to folder 'd:\workspace\ConsoleApplication1\packages'
Added package 'System.Runtime.4.0.0' to 'packages.config'
Successfully installed 'System.Runtime 4.0.0' to ConsoleApplication1
  GET https://www.nuget.org/api/v2/package/System.Runtime.Extensions/4.0.0
Installing System.Runtime.Extensions 4.0.0.
Adding package 'System.Runtime.Extensions.4.0.0' to folder 'd:\workspace\ConsoleApplication1\packages'
Added package 'System.Runtime.Extensions.4.0.0' to folder 'd:\workspace\ConsoleApplication1\packages'
Added package 'System.Runtime.Extensions.4.0.0' to 'packages.config'
Successfully installed 'System.Runtime.Extensions 4.0.0' to ConsoleApplication1
  GET https://www.nuget.org/api/v2/package/System.Threading/4.0.0
Installing System.Threading 4.0.0.
Adding package 'System.Threading.4.0.0' to folder 'd:\workspace\ConsoleApplication1\packages'
Added package 'System.Threading.4.0.0' to folder 'd:\workspace\ConsoleApplication1\packages'
Added package 'System.Threading.4.0.0' to 'packages.config'
Successfully installed 'System.Threading 4.0.0' to ConsoleApplication1
  GET https://www.nuget.org/api/v2/package/System.Collections.Immutable/1.1.37
Installing System.Collections.Immutable 1.1.37.
Adding package 'System.Collections.Immutable.1.1.37' to folder 'd:\workspace\ConsoleApplication1\packages'
Added package 'System.Collections.Immutable.1.1.37' to folder 'd:\workspace\ConsoleApplication1\packages'
Added package 'System.Collections.Immutable.1.1.37' to 'packages.config'
Successfully installed 'System.Collections.Immutable 1.1.37' to ConsoleApplication1

1 个答案:

答案 0 :(得分:1)

认为这是因为dotnet core / cli带来的变化。它维护了依赖链,这在donet核心中更为重要,因为您没有完全安装的框架。这解释了为什么lib\net45个文件夹为空,没有任何实际包含的内容,因为它们是您机器上安装的BCL的一部分。