简体   繁体   中英

Why are tons of packages added when I reference a .NET Standard NuGet from within .NET 461?

I have a .NET 461 project that references a NuGet targeting .NET Standard 1.6.

As i've understood by this answer , referecing this NuGet will cause my .NET 461 projects packages.config to look like the following:

<packages>
   ...
   <package id="NETStandard.Library" version="1.6.1" targetFramework="net46" />
   ...
</packages>

Actually, it looks more like this (there's like atleast 10 more that I haven't included here for simplicity):

<packages>
   ...
   <package id="NETStandard.Library" version="1.6.1" targetFramework="net46" />
   <package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="net46" /> 
   <package id="System.AppContext" version="4.3.0" targetFramework="net46" />
   <package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net46" /> 
   ...
</packages>

Is it NETStandard.Library that automagically references all these? I cannot find any information about this.

One of the recent improvements where packages we're moved from being referenced in packages.config to being referenced in project files was that they could implement a change wherein only your direct project dependencies are included in the file. Packages that those dependencies rely upon do not appear in the project file.

However, your snippet suggests that you're still using a packages.config file - in which case all dependencies in the transitive closure get included in the file, unfortunately, for backwards compatibility reasons.

Which specific packages you directly referenced (and which of those caused a particular package to appear in the packages.config due to a dependency) aren't recorded in this file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM