Change .NET target framework
Recipe ID
OpenRewrite.CSharp.Recipes.ChangeDotNetTargetFrameworkArtifactOpenRewrite.Recipes.CSharp.CoreChanges the <TargetFramework> or <TargetFrameworks> value in .csproj files. For multi-TFM projects, replaces the matching framework within the semicolon-delimited list.
Single recipeProprietary
Usage
You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe OpenRewrite.CSharp.Recipes.ChangeDotNetTargetFramework --recipe-option "OldTargetFramework=net8.0" --recipe-option "NewTargetFramework=net9.0"If the recipe isn’t available locally, install it with:
mod config recipes nuget install OpenRewrite.Recipes.CSharp.CoreOptions
| Name | Type | Description |
|---|---|---|
OldTargetFrameworkrequired | String | The target framework moniker to replace (e.g., net8.0). e.g. net8.0 |
NewTargetFrameworkrequired | String | The target framework moniker to use instead (e.g., net9.0). e.g. net9.0 |
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. |