Detect mono using PlatformAbstractions

This commit is contained in:
Henk Mollema 2016-01-07 00:48:36 +01:00
parent db11368d26
commit b4b5f07a08
3 changed files with 7 additions and 1 deletions

View File

@ -12,7 +12,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
{ {
IsWindows = PlatformApis.IsWindows; IsWindows = PlatformApis.IsWindows;
var isDarwinMono = !IsWindows && PlatformApis.IsDarwin; var isDarwinMono = PlatformApis.IsDarwin && PlatformApis.IsMono;
if (isDarwinMono) if (isDarwinMono)
{ {

View File

@ -3,6 +3,7 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Microsoft.Extensions.PlatformAbstractions;
namespace Microsoft.AspNet.Server.Kestrel.Networking namespace Microsoft.AspNet.Server.Kestrel.Networking
{ {
@ -24,12 +25,16 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
IsDarwin = string.Equals(GetUname(), "Darwin", StringComparison.Ordinal); IsDarwin = string.Equals(GetUname(), "Darwin", StringComparison.Ordinal);
} }
#endif #endif
IsMono = PlatformServices.Default.Runtime.RuntimeType == "Mono";
} }
public static bool IsWindows { get; } public static bool IsWindows { get; }
public static bool IsDarwin { get; } public static bool IsDarwin { get; }
public static bool IsMono { get; }
[DllImport("libc")] [DllImport("libc")]
static extern int uname(IntPtr buf); static extern int uname(IntPtr buf);

View File

@ -8,6 +8,7 @@
"dependencies": { "dependencies": {
"Microsoft.AspNet.Hosting": "1.0.0-*", "Microsoft.AspNet.Hosting": "1.0.0-*",
"Microsoft.Extensions.Logging.Abstractions": "1.0.0-*", "Microsoft.Extensions.Logging.Abstractions": "1.0.0-*",
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-*",
"System.Numerics.Vectors": "4.1.1-*", "System.Numerics.Vectors": "4.1.1-*",
"Microsoft.StandardsPolice": { "Microsoft.StandardsPolice": {
"version": "1.0.0-*", "version": "1.0.0-*",