删除Nuget软件包中的间接依赖关系

发布于 2025-02-03 14:20:12 字数 147 浏览 4 评论 0原文

我正在构建一个Nuget库(.NET标准),并且正在使用其他一些Nuget依赖项。

他们还有其他依赖性,我的代码不需要(我不使用使用该间接依赖的代码)。

有什么方法可以从我的包裹中删除未使用的间接依赖性,因此它会较小?

I'm building a NuGet library (.NET standard), and I'm using some other NuGet dependencies.

They have other dependencies that my code doesn't need (I don't use the code that use that indirect dependencies).

Is there any way to remove the unused indirect dependencies from my package, so it will be smaller?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蝶舞 2025-02-10 14:20:12

这些间接(或 transitive )依赖关系不会成为nuget软件包的一部分。 Nuget足够聪明,可以检测到并恢复Nuget上的及传递依赖性RETORERORE YORPACKAGE

您可以使用Dotpeek这样的工具打开nupkg文件时可以轻松检查此问题 - 您不会看到内部的瞬态依赖项。

或让我们 newtonsoft.json:请参阅,当目标.NET标准1.3,例如system.xml.xmldocument
但是,当查看
“ nofollow noreferrer”> in the Package ,它只是JSON.NET组件:

因此您不必担心。

Those indirect (or transitive) dependencies won't become part of your NuGet package. NuGet is smart enough to detect that and restore the transitive dependencies on nuget restore YourPackage.

You can easily check this when opening your nupkg file with a tool like dotPeek - you won't see the transient dependencies inside.

Or let's take Newtonsoft.Json: as you can see in the sources, a bunch of other packages are referenced when targeting .NET Standard 1.3, e. g. System.Xml.XmlDocument.
But when looking inside the package, it's only the Json.NET assembly:
enter image description here

So you don't have to worry about that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文