问题描述
我刚刚从(较旧的)Microsoft.Bcl.Immutable
NuGet 包切换到 System.Collections.Immutable
惊讶地发现我的项目中所有这些新的包依赖项:
I just switched from (an older) Microsoft.Bcl.Immutable
NuGet package to System.Collections.Immutable
and was surprised to find all these new package dependencies in my project:
System.Collections
System.Diagnostics.Debug
System.Globalization
System.Linq
System.Resources.ResourceManager
System.Runtime
System.Runtime.Extensions
System.Threading
它们被列为 NuGet 包的依赖项,因此它们有权在那里,但它们显然也已经安装在我的 PC 和我的目标环境 (Azure btw) 上,因为它们随框架一起提供.
They are listed as dependencies of the NuGet package, so they have a right to be there, yet they are obviously also already installed on my PC and my target environment (Azure btw) as they come with the framework.
我的项目中已经有大量的包,如果可能的话,我希望避免这 8 个包造成的额外开销(并且不会让自己陷入困境).
I already have a large number of packages in my project and would like to avoid the additional overhead caused by these 8 packages, if possible (and without shooting myself in the foot).
删除这些依赖项是否安全?
我现在是否必须在整个项目中使用这些包,因为它们可能与其安装的版本不同,并且我的项目的某些部分现在可能使用了错误的包?(由于某些 DLL 链接疯狂?)
Is it safe to remove these dependencies?
Do I now have to use these packages throughout my project because they might differ from their installed versions and some portion of my project might now use the wrong ones? (due to some DLL linking madness?)
只是为了完整起见,因为之前有评论:依赖项是实际的包(不是命名空间)并且必须下载,我的目标是使用 .NET 4.6 进行编译,正在工作在 VS2015 中.虽然有些东西已经过时并且包不必正常加载,但完全有可能?
Just for completeness, as there was a comment before: The dependencies are actual packages (not namespaces) and have to be downloaded, I'm targeting and compiling with .NET 4.6, working in VS2015. It's entirely possible though that something is outdated and the packages do not have to be loaded normally?
推荐答案
您只是看到了 Nuget 包的副作用,它必须让 很多 人开心.该软件包支持大量目标,最近它正在迅速增加.我看到了对 OSX 和 iOS、Windows Phone 8.0 和 8.1、Windows Store、CoreCLR(开源项目)、.NET 4.5、iOS 和 Android 的 MonoTouch 以及 .NETCore(Silverlight)的支持.
You are just seeing a side-effect of the Nuget package having to keep a lot of people happy. The package supports an enormous number of targets, it is proliferating rapidly as of late. I see support for Xamarin for OSX and iOS, Windows Phone 8.0 and 8.1, Windows Store, CoreCLR (the open source project), .NET 4.5, MonoTouch for iOS and Android and .NETCore (Silverlight).
这些依赖包只包含参考程序集,通常安装在您的 c:program files x86 eference assembly 目录中.Nuget 包不会冒险丢失此类参考程序集,它包含整个套件和 kaboodle.
These dependent packages just contain reference assemblies, the kind that are normally installed in your c:program files x86 eference assemblies directory. The Nuget package doesn't take the chance that such a reference assembly might be missing and includes the whole kit and kaboodle.
全部下载完成后,包安装程序运行并在项目中添加您实际需要的引用.很容易看到发生了什么,只需打开项目的 References 节点.如果您的目标是 .NET 4.5 及更高版本的桌面版本,则添加的引用总数为一个,只有 System.Collections.Immutable.是的,您可以删除它们.
After it is all downloaded, the package installer runs and adds the references you actually need in your project. Easy to see what happened, just open the References node of your project. If your targeted the desktop version of .NET 4.5 and up, the grand total of added references is one, just System.Collections.Immutable. Yes, you can remove them.
这篇关于我是否必须包含所有 System.Collections.Immutable 依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!