Description
Is your feature request related to a problem? Please describe.
Currently, .NET applications use a runtimeConfig to determine which runtime they run on. This is something that is determined at build time, but non-tool .NET applications can override this with various flags and environment variables given to the .NET runtime host. The default rollforward policy is LatestPatch
, which allows an application to run on any runtime of the same major/minor version that is at least as high a version as the application was built against.
.NET (local) Tools are a specific kind of .NET application that are intended to be distributed and managed via SDK commands. They are generally development tools/utilities. We think the semantics of tools are such that tools should be able to run on any .NET runtime equal or greater than the runtime the application originally targeted. This will reduce friction for users adopting new SDKS/Runtimes by not completely blocking their workflows without some explicit proof on incompatibility.
Without this change, tool authors must either explicitly set a more flexible roll-forward policy, or multitarget. Multitargeting has the side effect of increasing the overall size of the tool, and still not solving the issue - a tool that multitargets net6.0 and net7.0 will still not run on net8.0 runtimes.
Describe the solution you'd like
There are two places we could address this mismatch:
- build time, when a tool's RollForward defaults are baked into the resulting application
- install time, when any apphosts/runtimeConfigs are authored by the SDK for subsequent executions
Build Time changes
We would change the RollForward
of all tools from LatestPatch
to LatestMajor
. This would cause the desired behavior for all newly-built apps. We would also track a sentinel value that we set the RollForward, so that at install time we could tell if the user explicitly requested a change to the RollForward.
Install Time changes
We would ensure that tools that did not explicitly override to force a certain RollForward behavior would be written with LatestMajor
behavior. This helps us plug the existing behavior gap for tools that haven't been authored with an SDK containing these changes.
Additional context
- runtime-options (--roll-forward) for local tools #26824
- dotnet-suggest not available for .net 7 command-line-api#2014
- add rollforward policy to next-major fsprojects/FAKE#2372
- https://github.com/cake-build/cake/blob/develop/src/Shared.msbuild#L4
- Replace rollForward in tools runtimeconfig #24817
- existing SDK tools ship Major/LatestMajor already - evidence for the pattern being useful more widely
- EF also moved to a more aggressive rollforward: Update tool to roll forward to latest major version of runtime installed. efcore#27671