Retarget to .NET Framework 4.8
OpenRewrite.Recipes.CSharp.Migration.Dotnet.NetFramework.UpgradeToNetFramework48ArtifactOpenRewrite.Recipes.CSharp.Migration.DotnetRetargets a .NET Framework project to 4.8, the recommended modern target. Applies every intermediate minor-version step in order (4.0 -> 4.5 -> 4.5.1 -> 4.5.2 -> 4.6 -> 4.6.1 -> 4.6.2 -> 4.7 -> 4.7.1 -> 4.7.2 -> 4.8), updating <TargetFrameworkVersion> and <TargetFramework> in legacy and SDK-style csproj files, the <supportedRuntime sku> in app.config, and the targetFramework attribute in web.config at each step, and flagging affected source for review. Notable retargeting changes when reaching 4.8: managed crypto classes no longer throw in FIPS mode (Switch.System.Security.Cryptography.UseLegacyFipsThrow=true to revert); a third wave of accessibility improvements applies (keep legacy with all of Switch.UseLegacyAccessibilityFeatures, .2, and .3); HwndHost resizes correctly under per-monitor DPI; several WF/WPF checksum/hash defaults move to SHA-256. 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.UpgradeToNetFramework48If 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 .NET Framework 4.7.1 to 4.7.2
OpenRewrite.Recipes.CSharp.Migration.Dotnet.NetFramework.UpgradeToNetFramework472 - 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 - Find managed crypto classes (FIPS mode behavior change)
OpenRewrite.Recipes.CSharp.Migration.Dotnet.NetFramework.FindFipsManagedCryptoThrow