dotnet CLI/SDK and .NET runtime: Enable major roll-forward after a failed SDK upgrade?
0 reputation · 19 Feb 2022, 05:24 UTC
0 reputation · 19 Feb 2022, 05:24 UTC
When a .NET SDK upgrade fails, the CLI may still resolve to a newer SDK version if one is present, while applications continue to run on the existing runtime due to side‑by‑side installation. The roll‑forward policy allows an app targeting a specific runtime version to start on a newer patch or minor version, but major roll‑forward requires explicit opt‑in and can alter behavior after a failed upgrade. Administrators must decide whether to enable major roll‑forward globally to maintain availability, weighing the risk of unintended behavioral changes against downtime.
Verification can be performed by checking the CLI's list of runtimes and SDKs and by running a framework‑dependent test app with a pinned runtimeconfig to confirm which version is used after the failure.
34775 reputation · 19 Feb 2022, 15:00 UTC
No. Major roll-forward should not be enabled by default after a failed SDK upgrade. In .NET, major version increments often introduce breaking API changes, behavioral shifts in the Garbage Collector (GC), or JIT compiler optimizations that can lead to MethodNotFoundException or unpredictable performance regressions.
Because .NET runtimes are installed side-by-side, a failed SDK upgrade typically leaves the previous stable runtime intact. Enabling major roll-forward globally to maintain availability risks masking the installation failure and introducing runtime instability across your environment.
If you decide to opt-in to major roll-forward for specific workloads to maintain uptime, use the following scoped methods. This assumes you are using .NET Core 3.0 or later, where the DOTNET_ROLL_FORWARD policy was formalized.
You can enable this behavior via an environment variable or the application's configuration file:
DOTNET_ROLL_FORWARD=Major. This tells the host to use the highest installed major version if the targeted version is missing.<RollForward>Major</RollForward> element to the .runtimeconfig.json file of the specific application.To ensure the CLI is using the intended SDK and the application is using the expected runtime, execute these commands:
# List all installed SDKs and Runtimes to identify the current state
dotnet --list-sdks
dotnet --list-runtimes
# Verify which SDK is currently active for the current directory
dotnet --version
To verify that a framework-dependent app is actually rolling forward to a newer major version, run the app with the environment variable set and check the logs or use a diagnostic tool to print the runtime version.
Before deploying a major roll-forward policy, the following testing is required to mitigate risk:
Diagnostic Note: To provide a more specific recommendation, please clarify if you are using a global.json file to pin your SDK version, as this overrides the default CLI resolution logic.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.