Dotnet abort trap:6 on macOS Sierra


Hi - it seems like dotnet cli is broken on Sierra. I’ve filed some issues in github. See relevant output and clues below.
Pretty much a show stopping bug for me (as you can imagine)

Question: This is my first attempt at rebuilding a dotnet custom cli with some temporary fixes. I am familiar with github and open source development though. The code I want to tweak is in core-setup to build a patched dotnet cli. So I cloned and built with per instructions - it fails:

Publishing Archiver
             /Users/me/Dev/dotnet/cli/tools/Archiver> /Users/me/Dev/dotnet/cli/artifacts/osx.10.12-x64/stage2/dotnet publish  --configuration Debug    --output /Users/me/Dev/dotnet/cli/artifacts/osx.10.12-x64/tools
             Can not find runtime target for framework '.NETCoreApp,Version=v1.0' compatible with one of the target runtimes: 'osx.10.12-x64'. Possible causes:
             1. The project has not been restored or restore failed - run `dotnet restore`
             2. The project does not list one of 'osx.10.12-x64' in the 'runtimes' section.
             3. You may be trying to publish a library, which is not supported. Use `dotnet pack` to distribute libraries.
         1>/Users/me/Dev/dotnet/cli/build/compile/Microsoft.DotNet.Cli.LzmaArchive.targets(28,7): error MSB6006: "dotnet" exited with code 1. [/Users/me/Dev/dotnet/cli/build.proj]
         1>Done Building Project "/Users/me/Dev/dotnet/cli/build.proj" (default targets) -- FAILED.

    Build FAILED.

           "/Users/me/Dev/dotnet/cli/build.proj" (default target) (1) ->
           (GenerateNuGetPackagesArchive target) ->
             /Users/me/Dev/dotnet/cli/build/compile/Microsoft.DotNet.Cli.LzmaArchive.targets(28,7): error MSB6006: "dotnet" exited with code 1. [/Users/me/Dev/dotnet/cli/build.proj]

        0 Warning(s)
        1 Error(s)

So a few issues:

1 - which ‘runtimes’ section is missing osx.10.12.-x64 ?

2 - how do I set my project/environment up correctly to fix and install new native dlls (I’m guessing Microsoft.DotNet.PlatformAbstractions.dll)

3 - how do i set up the cli project to link to the proper dlls.

4 - there seems to be a lot of documentation, but I can’t find anything appropriate that covers changes in core-setup etc…

Thanks In advance for any assistance…

Trace output of any dotnet command:

The trace points to GetKernelRelease() in PlatformAbstractions

Unhandled Exception: System.TypeInitializationException: The type initializer for 'Microsoft.DotNet.InternalAbstractions.RuntimeEnvironment' threw an exception. ---> System.PlatformNotSupportedException: Error reading Darwin Kernel Version ---> System.DllNotFoundException: Unable to load DLL 'libc': The specified module could not be found.
 (Exception from HRESULT: 0x8007007E)
   at Microsoft.DotNet.InternalAbstractions.Native.NativeMethods.Darwin.sysctl(Int32* name, UInt32 namelen, Byte* oldp, UInt32* oldlenp, IntPtr newp, UInt32 newlen)
   at Microsoft.DotNet.InternalAbstractions.Native.NativeMethods.Darwin.GetKernelRelease()
   --- End of inner exception stack trace ---
   at Microsoft.DotNet.InternalAbstractions.Native.NativeMethods.Darwin.GetKernelRelease()
   at Microsoft.DotNet.InternalAbstractions.Native.PlatformApis.GetDarwinVersion()
   at Microsoft.DotNet.InternalAbstractions.Native.PlatformApis.GetOSVersion()
   at Microsoft.DotNet.InternalAbstractions.RuntimeEnvironment..cctor()
   --- End of inner exception stack trace ---
   at Microsoft.DotNet.InternalAbstractions.RuntimeEnvironment.GetRuntimeIdentifier()
   at Microsoft.DotNet.Cli.MulticoreJitProfilePathCalculator.CalculateProfileRootPath()
   at Microsoft.DotNet.Cli.MulticoreJitActivator.StartCliProfileOptimization()
   at Microsoft.DotNet.Cli.MulticoreJitActivator.TryActivateMulticoreJit()
   at Microsoft.DotNet.Cli.Program.Main(String[] args)
Abort trap: 6

Source : core-setup/src/Microsoft.DotNet.PlatformAbstractions/Native/PlatformApis.cs

private static string GetDarwinVersion()
	            Version version;
	            var kernelRelease = NativeMethods.Darwin.GetKernelRelease();
	            if (!Version.TryParse(kernelRelease, out version) || version.Major < 5)
	                // 10.0 covers all versions prior to Darwin 5
	                // Similarly, if the version is not a valid version number, but we have still detected that it is Darwin, we just assume
	                // it is OS X 10.0
	                return "10.0";
	                // Mac OS X 10.1 mapped to Darwin 5.x, and the mapping continues that way
	                // So just subtract 4 from the Darwin version.
	                return $"10.{version.Major - 4}";

.NET Foundation Website | Blog | Projects | Code of Conduct