Nuget Versioning: Wildcard vs unspecified component

Viewed 115

Reading the Nuget version documentation, I don't understand the difference between:

<PackageReference Include="ExamplePackage" Version="6.1" />

and:

<PackageReference Include="ExamplePackage" Version="6.1.*" />

If the actual package versions is 6.1.5. It seems like both meet the requirement (6.1.5 is greater than 6.1 and 6.1.0). I am assuming for this purpose that missing components (such as the 3rd component in the first example above) is implied to be 0 for the purposes of version comparison.

Can someone explain the semantic differences, if any?

1 Answers

If the actual package versions is 6.1.5. It seems like both meet the requirement [...]

Yes, they do.

I am assuming for this purpose that missing components [...] is implied to be 0 for the purposes of version comparison.

Correct, 6.1 and 6.1.0 are the same.

Can someone explain the semantic differences, if any?

In your first example, version 6.1 means that all package versions starting from 6.1.0 (inclusive) can be used, which implies 6.1.0, 6.1.5, but also 7.3.8-pre42. Due to the Lowest Applicable Version rule, when there are multiple packages that match the criteria, the lowest version will be used.

The second example is different, it uses a floating notation, which means that 6.1.* allows for all versions that start with 6.1, but the patch and pre-release versions can be anything like 6.1.5, 6.1.998 or 6.1.1-pre42. Consequently, you exclude all versions below 6.1.0 and starting with 6.2.0 and above, also for pre-releases. Here, the Floating versions rule applies, that restores the highest matching version.

In summary, both notations are not equivalent, the first represents an inclusive starting version, while the second only allows for a specific version with wildcards on the patch and prerelease number.

Related