Environment.OSVersion will now return the correct value for the OS
Previously Environment.OSVersion would return a version that may be incorrect on Windows if an application war running under compatibility mode, as mentioned here.
Now Environment.OSVersion will return the correct value.
Version introduced
.NET 5.0
Old behavior
Environment.OSVersion would return a version that may be incorrect when an application was running under Windows compatibility mode.
New behavior
Environment.OSVersion returns the actual version of the operating system.
Reason for change
Most users of this API expect it to return the actual version of the operating system. Most .NET applications do not specify their supported version in their application manifest, and thus get the default from the dotnet host. As a result the compatibility shim rarely is meaningful for the application that is running and they will typically get the actual version, except in cases where windows releases a new version and an older dotnet host is still in use. We felt that returning the actual version was more inline with the expectation of the users of this API.
Recommended action
Review and test any code that you have that uses Environment.OSVersion to ensure it behaves as desired.
Category
Affected APIs
Environment.OSVersion
dotnet/runtime#33643
dotnet/runtime#33651
Environment.OSVersion will now return the correct value for the OS
Previously
Environment.OSVersionwould return a version that may be incorrect on Windows if an application war running under compatibility mode, as mentioned here.Now
Environment.OSVersionwill return the correct value.Version introduced
.NET 5.0
Old behavior
Environment.OSVersionwould return a version that may be incorrect when an application was running under Windows compatibility mode.New behavior
Environment.OSVersionreturns the actual version of the operating system.Reason for change
Most users of this API expect it to return the actual version of the operating system. Most .NET applications do not specify their supported version in their application manifest, and thus get the default from the dotnet host. As a result the compatibility shim rarely is meaningful for the application that is running and they will typically get the actual version, except in cases where windows releases a new version and an older dotnet host is still in use. We felt that returning the actual version was more inline with the expectation of the users of this API.
Recommended action
Review and test any code that you have that uses Environment.OSVersion to ensure it behaves as desired.
Category
Affected APIs
Environment.OSVersion
dotnet/runtime#33643
dotnet/runtime#33651