@@ -223,11 +223,12 @@ private static bool CheckDirectoryForIcuBinaries(string directory, string librar
223
223
// Do a reverse sort so that we use the highest version
224
224
files . Sort ( ( x , y ) => string . CompareOrdinal ( y , x ) ) ;
225
225
var filePath = files [ 0 ] ;
226
+ var libNameLen = libraryName . Length ;
226
227
var version = IsWindows
227
- ? Path . GetFileNameWithoutExtension ( filePath ) . Substring ( 5 ) // strip icuuc
228
+ ? Path . GetFileNameWithoutExtension ( filePath ) . Substring ( libNameLen ) // strip icuuc
228
229
: IsMac
229
- ? Path . GetFileNameWithoutExtension ( filePath ) . Substring ( 9 ) // strip libicuuc.
230
- : Path . GetFileName ( filePath ) . Substring ( 12 ) ; // strip libicuuc.so.
230
+ ? Path . GetFileNameWithoutExtension ( filePath ) . Substring ( libNameLen + 4 ) // strip libicuuc.
231
+ : Path . GetFileName ( filePath ) . Substring ( libNameLen + 7 ) ; // strip libicuuc.so.
231
232
Trace . WriteLineIf ( Verbose , $ "icu.net: Extracted version '{ version } ' from '{ filePath } '") ;
232
233
if ( int . TryParse ( version , out var icuVersion ) )
233
234
{
@@ -255,38 +256,45 @@ private static bool LocateIcuLibrary(string libraryName)
255
256
}
256
257
257
258
var arch = IsRunning64Bit ? "x64" : "x86" ;
258
- // Look for ICU binaries in lib/{win,linux}-{x86,x64} subdirectory first
259
- var platform = IsWindows ? "win" : "linux" ;
259
+ var platform = IsWindows ? "win" : IsMac ? "osx" : "linux" ;
260
+
261
+ // Look for ICU binaries in lib/{win,osx,linux}-{x86,x64} subdirectory first
260
262
if ( CheckDirectoryForIcuBinaries (
261
263
Path . Combine ( DirectoryOfThisAssembly , "lib" , $ "{ platform } -{ arch } ") ,
262
264
libraryName ) )
263
265
return true ;
264
266
265
- // Next look in lib/x86 or lib/ x64 subdirectory
267
+ // Next look in lib/{ x86, x64} subdirectory
266
268
if ( CheckDirectoryForIcuBinaries (
267
269
Path . Combine ( DirectoryOfThisAssembly , "lib" , arch ) ,
268
270
libraryName ) )
269
271
return true ;
270
272
271
- // next try just {win,linux}-x86/ x64 subdirectory
273
+ // Next try just {win,osx, linux}-{ x86, x64} subdirectory
272
274
if ( CheckDirectoryForIcuBinaries (
273
275
Path . Combine ( DirectoryOfThisAssembly , $ "{ platform } -{ arch } ") ,
274
276
libraryName ) )
275
277
return true ;
276
278
277
- // next try just x86/ x64 subdirectory
279
+ // Next try just { x86, x64} subdirectory
278
280
if ( CheckDirectoryForIcuBinaries (
279
281
Path . Combine ( DirectoryOfThisAssembly , arch ) ,
280
282
libraryName ) )
281
283
return true ;
282
284
283
- // Might also be in runtimes/win7-x64/native
285
+ // Might be in runtimes/{win,osx,linux}/native
286
+ if ( CheckDirectoryForIcuBinaries (
287
+ Path . Combine ( DirectoryOfThisAssembly , "runtimes" , platform , "native" ) ,
288
+ libraryName ) )
289
+ return true ;
290
+
291
+ // Might also be in runtimes/win7-{x86,x64}/native
284
292
if ( CheckDirectoryForIcuBinaries (
285
293
Path . Combine ( DirectoryOfThisAssembly , "runtimes" , $ "win7-{ arch } ", "native" ) ,
286
294
libraryName ) )
287
295
return true ;
288
296
289
- // otherwise check the current directory
297
+ // Otherwise check the current directory
290
298
// If we don't find it here we rely on it being in the PATH somewhere...
291
299
return CheckDirectoryForIcuBinaries ( DirectoryOfThisAssembly , libraryName ) ;
292
300
}
0 commit comments