Corrected the Mac detection logic
This commit is contained in:
Родитель
3b9a7f9fde
Коммит
462c0806a9
|
@ -1,3 +1,4 @@
|
|||
using System.Runtime.InteropServices;
|
||||
|
||||
var RunNuGetRestore = new Action<FilePath> ((solution) =>
|
||||
{
|
||||
|
@ -82,8 +83,35 @@ var ClearSkiaSharpNuGetCache = new Action (() => {
|
|||
}
|
||||
});
|
||||
|
||||
internal static class MacPlatformDetector
|
||||
{
|
||||
internal static readonly Lazy<bool> IsMac = new Lazy<bool> (IsRunningOnMac);
|
||||
|
||||
[DllImport ("libc")]
|
||||
static extern int uname (IntPtr buf);
|
||||
|
||||
static bool IsRunningOnMac ()
|
||||
{
|
||||
IntPtr buf = IntPtr.Zero;
|
||||
try {
|
||||
buf = Marshal.AllocHGlobal (8192);
|
||||
// This is a hacktastic way of getting sysname from uname ()
|
||||
if (uname (buf) == 0) {
|
||||
string os = Marshal.PtrToStringAnsi (buf);
|
||||
if (os == "Darwin")
|
||||
return true;
|
||||
}
|
||||
} catch {
|
||||
} finally {
|
||||
if (buf != IntPtr.Zero)
|
||||
Marshal.FreeHGlobal (buf);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
var IsRunningOnMac = new Func<bool> (() => {
|
||||
return System.Environment.OSVersion.Platform == PlatformID.MacOSX;
|
||||
return System.Environment.OSVersion.Platform == PlatformID.MacOSX || MacPlatformDetector.IsMac.Value;
|
||||
});
|
||||
|
||||
var IsRunningOnLinux = new Func<bool> (() => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче