Skip to content

Environment.OSVersion will now return the correct value for the OS on Windows. #19684

Closed

Description

@ericstj

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

  • Core .NET libraries

Affected APIs

Environment.OSVersion

dotnet/runtime#33643
dotnet/runtime#33651

Activity

  1. added
    breaking-change
    on Jul 24, 2020
  2. self-assigned this
    on Jul 27, 2020
  3. added
    🏁 Release: .NET 5
    and removed
    ⌚ Not Triaged
    on Jul 27, 2020
  4. added a commit that references this issue on Aug 13, 2020
    e7ed722
  5. added a commit that references this issue on Aug 17, 2020
    acabd68
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

🏁 Release: .NET 5breaking-change

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions