← All recipes
Moderne licensed

Upgrade NuGet package version

Recipe IDOpenRewrite.CSharp.Recipes.UpgradeNuGetPackageVersionArtifactOpenRewrite.Recipes.CSharp.Core

Upgrades 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.Core

Options

NameTypeDescription
PackageNamerequiredStringThe NuGet package name to upgrade. Supports glob patterns.
e.g. Newtonsoft.Json
NewVersionrequiredStringAn 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
IncludePrereleaseBooleanWhether to include prerelease versions when resolving 'latest' or ranges.
RegenerateMarkerBooleanWhether 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.