diff --git a/LibGit2Sharp/Core/NativeMethods.cs b/LibGit2Sharp/Core/NativeMethods.cs index 219615f11..1fefd0bd3 100644 --- a/LibGit2Sharp/Core/NativeMethods.cs +++ b/LibGit2Sharp/Core/NativeMethods.cs @@ -68,7 +68,7 @@ private static string GetGlobalSettingsNativeLibraryPath() { return null; } - return Path.Combine(nativeLibraryDir, libgit2 + Platform.GetNativeLibraryExtension()); + return Path.Combine(nativeLibraryDir, Platform.GetNativeLibraryPrefix() + libgit2 + Platform.GetNativeLibraryExtension()); } private delegate bool TryLoadLibraryByNameDelegate(string libraryName, Assembly assembly, DllImportSearchPath? searchPath, out IntPtr handle); diff --git a/LibGit2Sharp/Core/Platform.cs b/LibGit2Sharp/Core/Platform.cs index 52859cbe2..4dd05fd91 100644 --- a/LibGit2Sharp/Core/Platform.cs +++ b/LibGit2Sharp/Core/Platform.cs @@ -56,6 +56,21 @@ public static OperatingSystemType OperatingSystem } } + public static string GetNativeLibraryPrefix() + { + switch (OperatingSystem) + { + case OperatingSystemType.MacOSX: + case OperatingSystemType.Unix: + return "lib"; + + case OperatingSystemType.Windows: + return string.Empty; + } + + throw new PlatformNotSupportedException(); + } + public static string GetNativeLibraryExtension() { switch (OperatingSystem)