Reputation: 13985
packages.config
contains all packages used by the project. version
attribute of package
element requires exact version of the package.
Meanwhile .nuspec
allows me to set the range of allowed versions of the dependency.
If my project depends on A
and B
, and they in turn both depend on C
, NuGet fetches the lowest possible version. So there is no hard fix of a version until exact version is specified in dependency [1.0]
. Then I do net get the point of having exact version in <package>
element. 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 >=
. It even supports floating versions
Upvotes: 2
Views: 554
Reputation: 1661
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. 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].
In the packages config when the user installs A-1.0, they will get B-1.0 as well. If the user chooses though, they can update package B to 2.0 and NuGet restore will still work.
Upvotes: 1