Use version range on project references #14719
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prerequisites
Description
When the current solution gets packaged (using
dotnet pack
), all project references will be converted to package dependencies that only specify the minimum version, for example:Umbraco.Cms 12.1.1
depends onUmbraco.Cms.Targets >= 12.1.1
. This allows other dependencies to (accidentally) update any of the transitive Umbraco dependencies to a next major version, which will most likely cause compilation or (worst-case) runtime errors.This can be prevented by setting the maximum version to the next major version as version range. Because the version is automatically generated and dependencies are specified in
ProjectReference
s, this version range must be dynamically set as well (better support for this has already been requested on the NuGet issue tracker). This PR contains an MSBuild target that updates the generated project reference version to use a version range, so when packaging version12.1.0--rc.preview.96.gfec51a9
, the dependency version is automatically updated to[12.1.0--rc.preview.96.gfec51a9, 13)
.Testing can be done by verifying whether the Umbraco dependencies in the NuGet packages contain the version range, either by inspecting the build artifacts or running
dotnet pack -c Release -o build.out
locally.