runtime: Environment.OSVersion.Platform returns Unix on macOS
Using .NET Core 2.0 SDK preview.
dotnet --info
:
.NET Command Line Tools (2.0.0-preview1-005977)
Product Information:
Version: 2.0.0-preview1-005977
Commit SHA-1 hash: 414cab8a0b
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.12
OS Platform: Darwin
RID: osx.10.12-x64
Base Path: /usr/local/share/dotnet/sdk/2.0.0-preview1-005977/
Microsoft .NET Core Shared Framework Host
Version : 2.0.0-preview1-002111-00
Build : 1ff021936263d492539399688f46fd3827169983
Simple test case:
[12:41pm yaakov@Eadu:/tmp/osver] dotnet new console
The template "Console Application" was created successfully.
Processing post-creation actions...
Running 'dotnet restore' on /private/tmp/osver/osver.csproj...
Restore succeeded.
[12:41pm yaakov@Eadu:/tmp/osver] vim Program.cs
[12:42pm yaakov@Eadu:/tmp/osver] cat Program.cs
using System;
namespace osver
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(Environment.OSVersion.Platform);
}
}
}
[12:42pm yaakov@Eadu:/tmp/osver] dotnet restore && dotnet build && dotnet run
Restoring packages for /private/tmp/osver/osver.csproj...
Lock file has not changed. Skipping lock file write. Path: /private/tmp/osver/obj/project.assets.json
Restore completed in 177.16 ms for /private/tmp/osver/osver.csproj.
NuGet Config files used:
/Users/yaakov/.nuget/NuGet/NuGet.Config
Feeds used:
https://api.nuget.org/v3/index.json
/Users/yaakov/.dotnet/NuGetFallbackFolder
Microsoft (R) Build Engine version 15.3.117.23532
Copyright (C) Microsoft Corporation. All rights reserved.
osver -> /private/tmp/osver/bin/Debug/netcoreapp2.0/osver.dll
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:02.29
Unix
[12:42pm yaakov@Eadu:/tmp/osver]
I would expect the program to print MacOSX
, i.e. System.PlatformID.MacOSX
which is enum value 6
.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 25 (23 by maintainers)
Commits related to this issue
- Fixing bass for MacOS loader https://github.com/dotnet/corefx/issues/19694 — committed to AddictedCS/soundfingerprinting.audio.bass by AddictedCS 5 years ago
This sounds reasonable to me. Maybe also hiding some of the other legacy/defunct values as well?