From d51c20f8f2e30e1597580e80b1bb15cb3c430098 Mon Sep 17 00:00:00 2001 From: Frederik Carlier Date: Mon, 28 Oct 2019 16:19:29 +0100 Subject: [PATCH 1/2] Add "lib" prefix to the native library name --- LibGit2Sharp/Core/NativeMethods.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LibGit2Sharp/Core/NativeMethods.cs b/LibGit2Sharp/Core/NativeMethods.cs index 219615f11..58407300c 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, "lib" + libgit2 + Platform.GetNativeLibraryExtension()); } private delegate bool TryLoadLibraryByNameDelegate(string libraryName, Assembly assembly, DllImportSearchPath? searchPath, out IntPtr handle); From 5231a00348b92a50a09ea5a072657066dcd3061d Mon Sep 17 00:00:00 2001 From: Frederik Carlier Date: Mon, 28 Oct 2019 16:28:11 +0100 Subject: [PATCH 2/2] Make prefix platform-dependent --- LibGit2Sharp/Core/NativeMethods.cs | 2 +- LibGit2Sharp/Core/Platform.cs | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/LibGit2Sharp/Core/NativeMethods.cs b/LibGit2Sharp/Core/NativeMethods.cs index 58407300c..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, "lib" + 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)