Upgrade NuGet package version
Recipe ID
OpenRewrite.CSharp.Recipes.UpgradeNuGetPackageVersionArtifactOpenRewrite.Recipes.CSharp.CoreUpgrades the version of a NuGet <PackageReference> or <PackageVersion> in .csproj and Directory.Packages.props files. Handles property references by updating the property value instead of the version attribute. Uses NuGet.Versioning for correct version semantics.
Single recipeProprietary
Usage
You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe OpenRewrite.CSharp.Recipes.UpgradeNuGetPackageVersion --recipe-option "PackageName=Newtonsoft.Json" --recipe-option "NewVersion=14.0.0"If the recipe isn’t available locally, install it with:
mod config recipes nuget install OpenRewrite.Recipes.CSharp.CoreOptions
| Name | Type | Description |
|---|---|---|
PackageNamerequired | String | The NuGet package name to upgrade. Supports glob patterns. e.g. Newtonsoft.Json |
NewVersionrequired | String | An exact version number, or a NuGet version range (e.g. '[14.0,)' for >= 14.0). Use 'latest' to upgrade to the latest available version from NuGet sources. e.g. 14.0.0 |
IncludePrerelease | Boolean | Whether to include prerelease versions when resolving 'latest' or ranges. |
RegenerateMarker | Boolean | Whether to re-run dotnet restore after the edit to refresh the project's MSBuildProject marker. Defaults to true. Composite recipes that chain multiple csproj-mutating steps may set this to false on intermediate steps and finalize once with EnsureCsprojAttestation. |