nuget 在多次获取相同依赖项时不检查版本

发布于 2024-11-25 04:58:09 字数 1201 浏览 0 评论 0原文

我的公司现在使用 nuget 来打包我们所有的共享程序集。我们还开始使用标签基于 semver 对它们进行版本控制。

我遇到的情况是 nuget 没有按我的预期工作。

我有 3 个共享程序集...

  • Enum
  • Common
  • BusinessLogic

就包引用而言...

  • Common =>枚举
  • BusinessLogic => Common、Enum

BusinessLogic 依赖 Common 和 Enum 的原因是,当不需要使用刚刚添加的新枚举时,我不想更新 Common 的依赖关系(以及重建、打包、发布)用于 BusinessLogic

因此,我添加一个枚举并希望在 BusinessLogic 中使用它。

这些是我执行此操作之前的所有内容的版本...

  • Enum = 1.4.0
  • Common = 1.2.1
  • BusinessLogic = 2.0.1

我现在将要在 BusinessLogic 中使用的新枚举值添加到 Enum 项目并构建、打包、发布...

  • Enum = 1.5.0
  • Common = 1.2.1
  • BusinessLogic = 2.0.1

现在,我对 BusinessLogic 进行更改,提交、推送、打包等...

  • Enum = 1.5.0
  • Common = 1.2.1
  • BusinessLogic = 2.1.0

所以,现在依赖关系看起来像这样......

  • Common =>枚举 1.4.0
  • 业务逻辑 => Enum 1.5.0

现在我运行...

nuget pack BusinessLogic.csproj

我期望发生的是 nuget 将看到 Common 需要 1.4.0 的 Enum,但 BusinessLogic 需要 1.5.0,因此将依赖项添加到包中 Enum >= 1.5.0,但是 Enum 中根本没有依赖关系,我认为这是假设 Common 会实现它。

这是设计使然吗?

My company are now using nuget to package all our shared assemblies. We've also started versioning them based on semver using tags.

I have a situation where nuget is not working as I would expect it to.

I have 3 shared assemblies....

  • Enum
  • Common
  • BusinessLogic

In terms of package references ...

  • Common => Enum
  • BusinessLogic => Common, Enum

the reason for BusinessLogic depending on both Common and Enum is that I don't want to have to update Common's dependancy (and rebuild, package, publish) when it doesn't need to use a new enum which has been added just for use in BusinessLogic

So, I add an enum and want to use it in BusinessLogic.

These are the versions of everything before I do that ...

  • Enum = 1.4.0
  • Common = 1.2.1
  • BusinessLogic = 2.0.1

I now add the new enum value I want to use in BusinessLogic to the Enum project and build, package, publish ...

  • Enum = 1.5.0
  • Common = 1.2.1
  • BusinessLogic = 2.0.1

Now, I make my change to BusinessLogic, commit, push, package, etc ...

  • Enum = 1.5.0
  • Common = 1.2.1
  • BusinessLogic = 2.1.0

So, now the dependancies look like this ...

  • Common => Enum 1.4.0
  • BusinessLogic => Enum 1.5.0

Now I run ...

nuget pack BusinessLogic.csproj

What I expect to happen is nuget will see that Common needs 1.4.0 of Enum, but BusinessLogic needs 1.5.0 and therefore add a dependancy into the package for Enum >= 1.5.0, but there is no dependancy in Enum at all, I think it's assuming that Common will fulfill it.

Is this behaviour by design?

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

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

发布评论

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

评论(1

剩一世无双 2024-12-02 04:58:09

我同意你的观点,目前的行为是不正确的。 nuget 尝试优化依赖项以将它们保持在最小集合,但没有考虑版本不同的情况。

您能否在 http://nuget.codeplex.com/ 上提交错误,以便它显示在雷达上?

作为目前的解决方法,您应该能够在用于构建 BusinessLogic 包的配套 .nuspec 文件中显式添加依赖项。

I agree with you that the current behavior is not correct. nuget tries to optimize the dependencies to keep them at a minimal set, but doesn't account for this case where the versions differ.

Could you please file a bug on http://nuget.codeplex.com/ so it shows up on the radar?

As a workaround for now, you should be able to add the dependency explicitly in the companion .nuspec file used to build the BusinessLogic package.

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