如何在 nuspec 中指定特定依赖项版本?
我正在创建我的第一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您应该能够强制使用带括号的精确版本:有关
您可以使用的格式的完整信息位于 NuGet 站点上,此处:
http://docs.nuget.org/docs/reference/version-range-specation
You should be able to force an exact version with brackets:
Full info on the formats you can use are on the NuGet site, here:
http://docs.nuget.org/docs/reference/version-range-specification
来自 NuGet 文档站点,完整的符号:
From the NuGet docs site, the complete notations:
根据 http://nuget.codeplex.com/wikipage?title=Dependency%20Resolution 和其他来源,只需指定下限 as
将导致与该版本匹配的最低主要/次要版本的最高修订/补丁级别。
除非我完全误解了文档,否则这将匹配最高的 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
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.
从用户方面,您还可以通过在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