@@ -20,6 +20,7 @@ public static class GlobalSettings
2020
2121 private static string nativeLibraryPath ;
2222 private static bool nativeLibraryPathLocked ;
23+ private static string nativeLibraryDefaultPath ;
2324
2425 static GlobalSettings ( )
2526 {
@@ -28,24 +29,14 @@ static GlobalSettings()
2829
2930 nativeLibraryPathAllowed = netFX || netCore ;
3031
31- if ( nativeLibraryPathAllowed )
32+ if ( netFX )
3233 {
33- string assemblyDirectory = GetExecutingAssemblyDirectory ( ) ;
34-
35- if ( netFX )
36- {
37- // For .NET Framework apps the dependencies are deployed to lib/win32/{architecture} directory
38- nativeLibraryPath = Path . Combine ( assemblyDirectory , "lib" , "win32" ) ;
39- }
40- else
41- {
42- // .NET Core apps that depend on native libraries load them directly from paths specified
43- // in .deps.json file of that app and the native library loader just works.
44- // However, .NET Core doesn't support .deps.json for plugins yet (such as msbuild tasks).
45- // To address that shortcoming we assume that the plugin deploys the native binaries to runtimes\{rid}\native
46- // directories and search there.
47- nativeLibraryPath = Path . Combine ( assemblyDirectory , "runtimes" , Platform . GetNativeLibraryRuntimeId ( ) , "native" ) ;
48- }
34+ // For .NET Framework apps the dependencies are deployed to lib/win32/{architecture} directory
35+ nativeLibraryDefaultPath = Path . Combine ( GetExecutingAssemblyDirectory ( ) , "lib" , "win32" ) ;
36+ }
37+ else
38+ {
39+ nativeLibraryDefaultPath = null ;
4940 }
5041
5142 registeredFilters = new Dictionary < Filter , FilterRegistration > ( ) ;
@@ -186,6 +177,10 @@ public static LogConfiguration LogConfiguration
186177 /// This must be set before any other calls to the library,
187178 /// and is not available on other platforms than .NET Framework and .NET Core.
188179 /// </para>
180+ /// <para>
181+ /// If not specified on .NET Framework it defaults to lib/win32 subdirectory
182+ /// of the directory where this assembly is loaded from.
183+ /// </para>
189184 /// </summary>
190185 public static string NativeLibraryPath
191186 {
@@ -196,7 +191,7 @@ public static string NativeLibraryPath
196191 throw new LibGit2SharpException ( "Querying the native hint path is only supported on .NET Framework and .NET Core platforms" ) ;
197192 }
198193
199- return nativeLibraryPath ;
194+ return nativeLibraryPath ?? nativeLibraryDefaultPath ;
200195 }
201196
202197 set
@@ -225,10 +220,8 @@ public static string NativeLibraryPath
225220 internal static string GetAndLockNativeLibraryPath ( )
226221 {
227222 nativeLibraryPathLocked = true ;
228-
229- return Platform . IsRunningOnNetFramework ( ) ?
230- Path . Combine ( nativeLibraryPath , Platform . ProcessorArchitecture ) :
231- nativeLibraryPath ;
223+ string result = nativeLibraryPath ?? nativeLibraryDefaultPath ;
224+ return Platform . IsRunningOnNetFramework ( ) ? Path . Combine ( result , Platform . ProcessorArchitecture ) : result ;
232225 }
233226
234227 /// <summary>
0 commit comments