简体   繁体   English

.nu​​spec 依赖版本和 packages.config 包版本如何相互关联?

[英]How does .nuspec dependency version and packages.config package version relate to each other?

packages.config contains all packages used by the project. packages.config包含项目使用的所有包。 version attribute of package element requires exact version of the package. package元素的version属性需要package 确切版本

Meanwhile .nuspec allows me to set the range of allowed versions of the dependency.同时.nuspec允许我设置依赖项的允许版本范围

If my project depends on A and B , and they in turn both depend on C , NuGet fetches the lowest possible version.如果我的项目依赖于AB ,而它们又都依赖于C ,则 NuGet 获取可能的最低版本。 So there is no hard fix of a version until exact version is specified in dependency [1.0] .因此,在依赖项[1.0]指定确切版本之前,没有版本的硬修复。 Then I do net get the point of having exact version in <package> element.然后我确实得到了在<package>元素中有确切版本的点。 And it does not have >= semantics because if package with the exact version does not exist, package restore fails.并且它没有>=语义,因为如果具有确切版本的包不存在,则包还原失败。

Contrary to that, recently introduced PackageReference treats version as >= .与此相反,最近引入的PackageReferenceversion视为>= It even supports floating versions它甚至支持浮动版本

They are different contexts, one is the package author specifying dependencies of his package, the other one is the user control over the package versions.它们是不同的上下文,一种是包作者指定其包的依赖关系,另一种是用户对包版本的控制。

The nuspec dependency versions are basically specifying which version of the dependent package you can use. nuspec 依赖版本基本上是指定您可以使用哪个版本的依赖包。 Basically you are saying that your package will only work if installed side-by-side with that version range of the dependant package.基本上你是说你的包只有在与依赖包的那个版本范围并排安装时才能工作。

On the other hand, the value in the version attribute of package is user control.另一方面,包的版本属性中的值是用户控制。 Say you have Package A version 1.0, which depends on Package B range [1.0,2.0].假设您有 Package A 版本 1.0,这取决于 Package B 范围 [1.0,2.0]。

In the packages config when the user installs A-1.0, they will get B-1.0 as well.在用户安装 A-1.0 的包配置中,他们也将获得 B-1.0。 If the user chooses though, they can update package B to 2.0 and NuGet restore will still work.如果用户选择,他们可以将包 B 更新到 2.0,并且 NuGet 还原仍然有效。

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

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