简体   繁体   English

dll 文件依赖与 nuget 包参考混淆

[英]dll file dependency mess with nuget packagereference

Our team provides multiple nuget SDKs for users to refer to.我们团队提供了多个nuget SDK供用户参考。 Every nuget file we created will contain its own project dll file and its dependency dll files.我们创建的每个 nuget 文件都将包含其自己的项目 dll 文件及其依赖项 dll 文件。

This caused us problem when users try to use more than one nuget sdks.当用户尝试使用多个 nuget sdks 时,这给我们带来了问题。 Especially when those nugets contain different version of same dll dependency.特别是当这些 nuget 包含相同 dll 依赖项的不同版本时。

For example, nuget A contains a.dll.例如,nuget A 包含 a.dll。 nuget B(depends on nuget A) contains both a.dll and b.dll because of dependency auto parsing. nuget B(取决于 nuget A)同时包含 a.dll 和 b.Z06416233FE7FF23B159C377F9BZ A 和 b.Z06416233FE7FF23B159C377F933 的依赖关系。 If users add reference to both nuget A and B, and when there is any change in a.dll, we need to update both nuget A and B and ask our use to update to lastest nuget A and B at the same time. If users add reference to both nuget A and B, and when there is any change in a.dll, we need to update both nuget A and B and ask our use to update to lastest nuget A and B at the same time.

This has caused us lots of trouble when amount of nugets we own increases.当我们拥有的 nugets 数量增加时,这给我们带来了很多麻烦。 And every time we make some changes we have to update all nugets we support.每次我们进行一些更改时,我们都必须更新我们支持的所有 nuget。 Is there any way we can limit one dll dependency to be only in one nuget?有什么办法可以将一个 dll 依赖项限制在一个 nuget 中? Then we only need to update one nuget when some update happens.然后我们只需要更新一个 nuget 时发生一些更新。

Thanks谢谢

Every nuget file we created will contain its own project dll file and its dependency dll files.我们创建的每个 nuget 文件都将包含其自己的项目 dll 文件及其依赖项 dll 文件。

That's the problem.那就是问题所在。 Each NuPkg file should only contain its own libraries, but declare its dependencies on other packages.每个 NuPkg 文件应该只包含它自己的库,但声明它对其他包的依赖关系。 That's the default behavior when a NuPkg file is packed, so presumably you've got additional bits in either your.nuspec file or your.csproj file to include the dependency libraries... just remove those.这是打包 NuPkg 文件时的默认行为,因此大概您在 your.nuspec 文件或 your.csproj 文件中添加了额外的位以包含依赖库......只需删除那些。

Once each package only contains its own library, you're back to the "expected" situation and clients should be able to just depend on one of them, and the tooling will resolve dependencies transitively.一旦每个 package 只包含自己的库,您就会回到“预期”的情况,客户端应该能够只依赖其中一个,并且工具将传递地解决依赖关系。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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