Skip to content

Commit cdab62d

Browse files
committed
Fix netfx build
1 parent 94b95dd commit cdab62d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

LibGit2Sharp/Core/NativeMethods.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ static NativeMethods()
6161
InitializeNativeLibrary();
6262
}
6363

64-
private delegate bool TryLoadLibraryByNameDelegate(string libraryName, Assembly assembly, DllImportSearchPath? searchPath, out IntPtr handle);
65-
private delegate bool TryLoadLibraryByPathDelegate(string libraryPath, out IntPtr handle);
66-
6764
private static string GetGlobalSettingsNativeLibraryPath()
6865
{
6966
string nativeLibraryDir = GlobalSettings.GetAndLockNativeLibraryPath();
@@ -74,6 +71,9 @@ private static string GetGlobalSettingsNativeLibraryPath()
7471
return Path.Combine(nativeLibraryDir, libgit2 + Platform.GetNativeLibraryExtension());
7572
}
7673

74+
private delegate bool TryLoadLibraryByNameDelegate(string libraryName, Assembly assembly, DllImportSearchPath? searchPath, out IntPtr handle);
75+
private delegate bool TryLoadLibraryByPathDelegate(string libraryPath, out IntPtr handle);
76+
7777
static TryLoadLibraryByNameDelegate _tryLoadLibraryByName;
7878
static TryLoadLibraryByPathDelegate _tryLoadLibraryByPath;
7979

@@ -146,13 +146,14 @@ private static IntPtr ResolveDll(string libraryName, Assembly assembly, DllImpor
146146
return handle;
147147
}
148148

149+
#if NETFRAMEWORK
150+
#else
149151
// We cary a number of .so files for Linux which are linked against various
150152
// libc/OpenSSL libraries. Try them out.
151153
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
152154
{
153155
// The libraries are located at 'runtimes/<rid>/native/lib{libraryName}.so'
154156
// The <rid> ends with the processor architecture. e.g. fedora-x64.
155-
156157
string assemblyDirectory = Path.GetDirectoryName(typeof(NativeMethods).Assembly.Location);
157158
string processorArchitecture = RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant();
158159
foreach (var runtimeFolder in Directory.GetDirectories(Path.Combine(assemblyDirectory, "runtimes"), $"*-{processorArchitecture}"))
@@ -164,6 +165,7 @@ private static IntPtr ResolveDll(string libraryName, Assembly assembly, DllImpor
164165
}
165166
}
166167
}
168+
#endif
167169
}
168170
return handle;
169171
}

0 commit comments

Comments
 (0)