如何在 nuspec 中指定特定依赖项版本?

发布于 2024-12-10 06:49:07 字数 590 浏览 0 评论 0原文

我正在创建我的第一个 nuget 包。我添加了一个不是最新版本的依赖项。但是,我不想更新到此依赖项的最新版本。是否可以指示它使用特定版本?

<dependencies>
  <dependency id="NHibernate" version="3.2.0.3001" />
</dependencies>

当我安装该软件包时,我会看到以下内容:

Attempting to resolve dependency 'NHibernate (≥ 3.2.0.3001)'.

当我安装该软件包时,这会创建以下内容。

<packages>
  <package id="Iesi.Collections" version="3.2.0.4000" />
  <package id="NHibernate" version="3.2.0.4000" />
</packages>

我真的很想看到这样的东西: 尝试解决依赖项“NHibernate (3.2.0.3001)”。

I'm creating my first nuget package. I added a dependency with a version that is not the latest version. However, I don't want to update to the latest version of this dependency. Is it possible to instruct it to use the specific version?

<dependencies>
  <dependency id="NHibernate" version="3.2.0.3001" />
</dependencies>

When I install the package I see this:

Attempting to resolve dependency 'NHibernate (≥ 3.2.0.3001)'.

This creates the following when I install the package.

<packages>
  <package id="Iesi.Collections" version="3.2.0.4000" />
  <package id="NHibernate" version="3.2.0.4000" />
</packages>

I'd really like to see something like this:
Attempting to resolve dependency 'NHibernate (3.2.0.3001)'.

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

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

发布评论

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

评论(4

誰認得朕 2024-12-17 06:49:07

您应该能够强制使用带括号的精确版本:有关

<dependency id="NHibernate" version="[3.2.0.3001]" />

您可以使用的格式的完整信息位于 NuGet 站点上,此处:

http://docs.nuget.org/docs/reference/version-range-specation

You should be able to force an exact version with brackets:

<dependency id="NHibernate" version="[3.2.0.3001]" />

Full info on the formats you can use are on the NuGet site, here:

http://docs.nuget.org/docs/reference/version-range-specification

忘东忘西忘不掉你 2024-12-17 06:49:07

来自 NuGet 文档站点,完整的符号:

在此处输入图像描述

From the NuGet docs site, the complete notations:

enter image description here

狂之美人 2024-12-17 06:49:07

根据 http://nuget.codeplex.com/wikipage?title=Dependency%20Resolution 和其他来源,只需指定下限 as

<dependencies>
  <dependency id="NHibernate" version="3.2.0.3001" />
</dependencies>

将导致与该版本匹配的最低主要/次要版本的最高修订/补丁级别。

除非我完全误解了文档,否则这将匹配最高的 3.2.* 版本,但不匹配 3.3.* 或更高版本,除非找不到 3.2.* 版本。

如果出于某种原因,3.2.0.3001 是您希望依赖的唯一版本,您可能会发现您的软件包与其他也依赖于 NHibernate 的软件包不兼容,例如,因为其他软件包依赖于 NHibernate [3.2.0.3002 ,3.3) 这意味着至少 3.2.0.3002 但低于 3.3。

According to http://nuget.codeplex.com/wikipage?title=Dependency%20Resolution and other sources, simply specifying the lower bound as

<dependencies>
  <dependency id="NHibernate" version="3.2.0.3001" />
</dependencies>

will result in the highest revision/patch level of the lowest major/minor version matching that version.

Unless I completely misunderstand the documentation, this would match the highest 3.2.* version but not 3.3.* or greater versions unless no 3.2.* version could be found.

If there is some reason why 3.2.0.3001 is the only version against which you wish to depend, you may find that your package is not compatible with other packages which also depend on NHibernate for example because the other package depends on NHibernate [3.2.0.3002,3.3) which means at least 3.2.0.3002 but lower than 3.3.

没企图 2024-12-17 06:49:07

从用户方面,您还可以通过在packages.config中指定allowedVersions来限制升级。
http://docs.nuget.org/docs/reference/versioning#Constraining_Upgrades_To_Allowed_Versions

From the user side, you can also constrain the upgrade by specifying allowedVersions in the packages.config.
http://docs.nuget.org/docs/reference/versioning#Constraining_Upgrades_To_Allowed_Versions

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