Skip to content

Environment.OSVersion returns the incorrect value for macOS 12 Monterey #58575

Closed

Description

@al-cheb

[Environment]::OSVersion.Version.ToString() should return 12.0.0.

Current behavior:

PS > [Environment]::OSVersion

Platform ServicePack Version VersionString
-------- ----------- ------- -------------
    Unix             11.0.0  Unix 11.0.0

PS > sw_vers
ProductName:    macOS
ProductVersion: 12.0
BuildVersion:   21A5304g

PS >  sysctl -a| grep -e release -e version
user.posix2_version: 200112
kern.osrelease: 21.0.0
kern.version: Darwin Kernel Version 21.0.0: Mon Aug  2 00:18:11 PDT 2021; root:xnu-8019.30.9~9/RELEASE_X86_64
kern.posix1version: 200112
kern.osversion: 21A5304g
kern.iossupportversion: 15.0
kern.osproductversion: 12.0
kern.osproductversioncompat: 10.16
kern.osreleasetype: User
kern.system_version_compat: 0
vm.fault_resilient_media_release: 0
vm.shared_region_version: 3
net.inet.igmp.default_version: 3
net.inet.tcp.mptcp_preferred_version: 0
net.inet6.ip6.kame_version: 2009/apple-darwin
net.mpklog.version: 1
machdep.cpu.arch_perf.version: 1
machdep.cpu.microcode_version: 1070
security.mac.asp.active_rule_version: 10415043430518216312
security.mac.asp.stats.cache_release_count: 0

PS > dotnet --info
.NET SDK (reflecting any global.json):
 Version:   5.0.400
 Commit:    d61950f9bf

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  11.0
 OS Platform: Darwin
 RID:         osx-x64
 Base Path:   /Users/runner/.dotnet/sdk/5.0.400/

Host (useful for support):
  Version: 5.0.9
  Commit:  208e377a53

Expected value:

PS > [Environment]::OSVersion

Platform ServicePack Version VersionString
-------- ----------- ------- -------------
    Unix             12.0.0  Unix 12.0.0

Activity

  1. KalleOlaviNiemitalo commented on Sep 1, 2021

    @KalleOlaviNiemitalo

    I guess it comes from

    if (major == 10 && minor == 16)
    {
    // We get "compat" version for 11.0 unless we build with updated SDK.
    // Hopefully that will be before 11.x comes out
    // For now, this maps 10.16 to 11.0.
    major = 11;
    minor = 0;
    }
    .

    Does this mean the .NET Runtime is not yet built "with updated SDK"?

  2. transferred this issue fromdotnet/sdkon Sep 2, 2021
  3. ghost added
    untriaged
    on Sep 2, 2021
  4. added this to the 6.0.0 milestone on Sep 2, 2021
  5. removed
    untriaged
    on Sep 2, 2021
  6. vcsjones commented on Sep 10, 2021

    @vcsjones
    Member

    I can't reproduce this in .NET 6, I think this is something that only applies to .NET 5 and 3.1.

    Both the API and and dotnet --info are seem correct for 6.0 on my M1 Mac.

    image

    image

  7. vcsjones commented on Sep 10, 2021

    @vcsjones
    Member

    This is interesting - it seems that macOS freezes the version you get depending on what SDK you build it with. Based on the code above, it seems that it's getting 10.16 from the OS. It isn't "updating its lie" as 10.17 or similar.

    If I tell macOS to not lie about the version, PowerShell starts working accordingly.

    image

    If what I said about the version being fixed based on the SDK, then #41012 may need to be revisited.

  8. chucker commented on Sep 10, 2021

    @chucker

    I guess it comes from

    if (major == 10 && minor == 16)
    {
    // We get "compat" version for 11.0 unless we build with updated SDK.
    // Hopefully that will be before 11.x comes out
    // For now, this maps 10.16 to 11.0.
    major = 11;
    minor = 0;
    }

    .
    Does this mean the .NET Runtime is not yet built "with updated SDK"?

    Can’t .NET simply set SYSTEM_VERSION_COMPAT = 0 and get rid of the above code altogether?

  9. wfurt commented on Sep 10, 2021

    @wfurt
    Member

    Since this is global the real question is what else is impacted. I'll check if we can get the real version via sysctl. Also I'm not sure what is oldest version we need to support @danmoseley. Perhaps it is also time to update the SDK we use.

  10. wfurt commented on Sep 13, 2021

    @wfurt
    Member

    I got VM up and @vcsjones was right. 6.0 works as expeced and return 12.0 as it it should. This is probably because we use updated SDK and OS does not lie to us.
    So we should service 5.0 (and perhaps 3.1) @danmoseley but this should not impact 6.0 as far as I can tell.

  11. danmoseley commented on Sep 13, 2021

    @danmoseley
    Contributor

    Minimum supported versions are documented here

    https://github.com/dotnet/core/blob/main/os-lifecycle-policy.md

    6.0 : 10.14
    3.1 and 5.0 : 10.13

    Highest supported macOS versions are not documented there but historically I believe we have aimed for .NET versions still in support to support the latest released macOS as generally folks upgrade macOS eagerly. @leecow is that right?

  12. modified the milestones: 6.0.0, 7.0.0 on Sep 22, 2021
  13. jeffhandley commented on Sep 22, 2021

    @jeffhandley
    Member

    Moved to 7.0.0 milestone to reflect that this does not affect 6.0. Even though it also won't affect 7.0.0, we'll want to service 5.0 and possibly 3.1 for this if there's enough justification, so this will be on the radar during the 7.0.0 milestone.

  14. added
    backlog-cleanup-candidate
    on Jul 9, 2022
  15. modified the milestones: 7.0.0, Future on Jul 10, 2022
  16. ghost removed
    backlog-cleanup-candidate
    on Jul 10, 2022
  17. locked and limited conversation to collaborators on Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions