Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the intended way to target a specific version of the .NET Runtime? #25220

Closed
handerss-spotfire opened this issue May 5, 2022 · 4 comments
Labels

Comments

@handerss-spotfire
Copy link

As far as I can tell the runtime version required to run a .NET application has to be greater or equal to the version of the .NET SDK which built the application [1]. E.g. if I build a net6.0-window Forms project using .NET SDK 6.0.202 then the dll will have references to "System.Windows.Forms (6.0.2)" making it unable to run (or be built as a referenced package) by an older version.

The way to solve this seems to either be to force the .NET SDK version via global.json [2], or add FrameworkReference [3] attributes for each of the referenced frameworks.

Adding a global.json which prohibits rollForward doesn't work well since the installed version of the SDK changes all the time. E.g. if I install .NET SDK 6.0.100 (which corresponds to 6.0.0 runtime) it will eventually be updated by Windows to some newer or patched version like 6.0.100-rc.1.21458.32 or 6.0.104. This breaks builds since these are not compatible with the global.json. Using the dotnet-install script also does not seem to work well since neither 6.0.0 or 6.0.100 are resolved.

It is also very unclear how the .NET SDK version corresponds to the runtime version used. E.g. .NET SDK 6.0.202 (and 6.0.104) installs the 6.0.4 runtime [4]. This means that I can't set rollForward to "patch" since that may result in a newer runtime. As far I can tell there is no way to look at the SDK version and know what runtime version I will get.

Using FrameworkReference is poorly documented and seems to require that each referenced framework is explicitly added.

Since .NET is backwards compatible within MAJOR version I want to target the lowest possible runtime, and then allow the person running my application to select whichever is the most appropriate runtime for them. I also don't want to force projects which depend on my package to use a newer SDK version than what is necessary.

How is this problem meant to be solved?

[1]: dotnet/winforms#6663 (comment), dotnet/winforms#6663 (comment), dotnet/winforms#6663 (comment)
[2]: dotnet/winforms#6663 (comment)
[3]: dotnet/core#7176 (comment)
[4]: https://dotnet.microsoft.com/en-us/download/dotnet/6.0

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-CLI untriaged Request triage from a team member labels May 5, 2022
@jhudsoncedaron
Copy link

I don't understand. Is there a reason doesn't work?

@handerss-spotfire
Copy link
Author

As far as I understand it the minimum required runtime version is determined by the SDK version used to compile a project. So if I am not paying attention then my application may change the required runtime version despite my TargetFramework not changing. A customer could be using 6.0.0 to run my application and then after an update it may require them to use 6.0.2 or higher despite my project not changing in any way outside of which SDK was used to build it.

This is problematic since Windows automatically updates the .NET SDK making this scenario very likely.

@gkulin gkulin added needs team triage Requires a full team discussion and removed untriaged Request triage from a team member labels May 23, 2022
@marcpopMSFT
Copy link
Member

Normally the SDK will use the minimum possible runtime version in the runtimeconfig (aka 6.0.0). Please see this known issue which discusses what happened with the 6.0.2 Windows Desktop runtime release. It looks like you've already seen some of the issues around this but that document should include the summary of what happened and workaround in that particular case.

Normally customers should not have to configure a specific runtime version.

@marcpopMSFT marcpopMSFT removed the needs team triage Requires a full team discussion label May 25, 2022
@handerss-spotfire
Copy link
Author

@marcpopMSFT So this comment is only in reference to the Windows Desktop issue? Because the way it is worded seems to indicate that it is a general property.

Normally the SDK will use the minimum possible runtime version in the runtimeconfig (aka 6.0.0).

So setting RuntimeFrameworkVersion should be enough then (this property is buried under "Self-contained deployments include the selected runtime" despite also applying to non self-contained applications)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants