@@ -20,6 +20,7 @@ public static class GlobalSettings
20
20
21
21
private static string nativeLibraryPath ;
22
22
private static bool nativeLibraryPathLocked ;
23
+ private static string nativeLibraryDefaultPath ;
23
24
24
25
static GlobalSettings ( )
25
26
{
@@ -28,24 +29,14 @@ static GlobalSettings()
28
29
29
30
nativeLibraryPathAllowed = netFX || netCore ;
30
31
31
- if ( nativeLibraryPathAllowed )
32
+ if ( netFX )
32
33
{
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 ;
49
40
}
50
41
51
42
registeredFilters = new Dictionary < Filter , FilterRegistration > ( ) ;
@@ -186,6 +177,10 @@ public static LogConfiguration LogConfiguration
186
177
/// This must be set before any other calls to the library,
187
178
/// and is not available on other platforms than .NET Framework and .NET Core.
188
179
/// </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>
189
184
/// </summary>
190
185
public static string NativeLibraryPath
191
186
{
@@ -196,7 +191,7 @@ public static string NativeLibraryPath
196
191
throw new LibGit2SharpException ( "Querying the native hint path is only supported on .NET Framework and .NET Core platforms" ) ;
197
192
}
198
193
199
- return nativeLibraryPath ;
194
+ return nativeLibraryPath ?? nativeLibraryDefaultPath ;
200
195
}
201
196
202
197
set
@@ -225,10 +220,8 @@ public static string NativeLibraryPath
225
220
internal static string GetAndLockNativeLibraryPath ( )
226
221
{
227
222
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 ;
232
225
}
233
226
234
227
/// <summary>
0 commit comments