Change .NET target framework

Proprietary

Changes the <TargetFramework> or <TargetFrameworks> value in .csproj files. For multi-TFM projects, replaces the matching framework within the semicolon-delimited list.

OpenRewrite.CSharp.Recipes.ChangeDotNetTargetFramework

Required

The target framework moniker to replace (e.g., net8.0).

The target framework moniker to use instead (e.g., net9.0).

Optional

RegenerateMarkerBoolean

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.

mod run . --recipe=OpenRewrite.CSharp.Recipes.ChangeDotNetTargetFramework \ -P OldTargetFramework=net8.0 \ -P NewTargetFramework=net9.0

Install it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.