Retarget to .NET Framework 4.8.1
OpenRewrite.Recipes.CSharp.Migration.Dotnet.NetFramework.UpgradeToNetFramework481ArtifactOpenRewrite.Recipes.CSharp.Migration.DotnetRetargets a .NET Framework project to 4.8.1, applying the full 4.0 -> 4.8 chain and then bumping to 4.8.1. Updates <TargetFrameworkVersion> to v4.8.1, <TargetFramework> to net481, the app.config <supportedRuntime sku>, and the web.config targetFramework. .NET Framework 4.8.1 introduced no application-compatibility (retargeting) changes, so this step is purely the version bump. **Compatibility caveat:** 4.8.1 requires Windows 11 (21H2+) or Windows Server 2022+ at runtime and Visual Studio 2022 17.3+ to build, and is the only 4.x release with native Arm64 support. If any target machine runs Windows 10 or older Windows Server, stop at UpgradeToNetFramework48 instead. See https://learn.microsoft.com/en-us/dotnet/framework/migration-guide/retargeting/4.8.x.
Usage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe OpenRewrite.Recipes.CSharp.Migration.Dotnet.NetFramework.UpgradeToNetFramework481If the recipe isn’t available locally, install it with:
mod config recipes nuget install OpenRewrite.Recipes.CSharp.Migration.DotnetDefinition
This recipe runs the following recipes in order.
- Retarget to .NET Framework 4.8
OpenRewrite.Recipes.CSharp.Migration.Dotnet.NetFramework.UpgradeToNetFramework48 - Change .NET Framework version
OpenRewrite.CSharp.Recipes.ChangeDotNetFrameworkVersion - Change .NET target framework
OpenRewrite.CSharp.Recipes.ChangeDotNetTargetFramework - Change web.config target framework
OpenRewrite.CSharp.Recipes.ChangeWebConfigTargetFramework - Ensure csproj attestation
OpenRewrite.CSharp.Recipes.EnsureCsprojAttestation