diff --git a/Source/Libs/Shared/FuncLoader.cs b/Source/Libs/Shared/FuncLoader.cs index d94c6710a..118cdd039 100644 --- a/Source/Libs/Shared/FuncLoader.cs +++ b/Source/Libs/Shared/FuncLoader.cs @@ -30,12 +30,37 @@ class FuncLoader public static extern IntPtr dlsym(IntPtr handle, string symbol); } - private static bool IsWindows, IsOSX; + [DllImport("libc")] + private static extern int uname(IntPtr buf); + + public static bool IsWindows, IsOSX; static FuncLoader() { - IsWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); - IsOSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX); + switch (Environment.OSVersion.Platform) + { + case PlatformID.Win32NT: + case PlatformID.Win32S: + case PlatformID.Win32Windows: + case PlatformID.WinCE: + IsWindows = true; + break; + case PlatformID.MacOSX: + IsOSX = true; + break; + case PlatformID.Unix: + try + { + var buf = Marshal.AllocHGlobal(8192); + if (uname(buf) == 0 && Marshal.PtrToStringAnsi(buf) == "Darwin") + IsOSX = true; + + Marshal.FreeHGlobal(buf); + } + catch { } + + break; + } } public static IntPtr LoadLibrary(string libname) diff --git a/Source/Libs/Shared/GLibrary.cs b/Source/Libs/Shared/GLibrary.cs index 87dae281e..3503952be 100644 --- a/Source/Libs/Shared/GLibrary.cs +++ b/Source/Libs/Shared/GLibrary.cs @@ -47,9 +47,9 @@ class GLibrary var i = _libdict.Find((e) => e.Library == library); var s = i.LinuxLib; - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + if (FuncLoader.IsWindows) s = i.WindowsLib; - else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + else if (FuncLoader.IsOSX) s = i.OSXLib; _libraries[library] = ret = FuncLoader.LoadLibrary(s); diff --git a/build.cake b/build.cake index 5263aea04..28f31335a 100755 --- a/build.cake +++ b/build.cake @@ -6,7 +6,7 @@ // VARS Settings.Cake = Context; -Settings.Version = "3.22.24.28"; +Settings.Version = "3.22.24.29"; Settings.BuildTarget = Argument("BuildTarget", "Default"); Settings.Assembly = Argument("Assembly", "");