diff --git a/Directory.Build.props b/Directory.Build.props index ed16290..fc8154e 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -12,7 +12,7 @@ https://www.hdfgroup.org/ HDF.PInvoke https://github.com/HDFGroup/HDF.PInvoke.1.10 - 1.10.612 + 1.10.613 diff --git a/src/HDF.PInvoke.1.10/H5DLLImporter.cs b/src/HDF.PInvoke.1.10/H5DLLImporter.cs index b299e23..7ba5491 100644 --- a/src/HDF.PInvoke.1.10/H5DLLImporter.cs +++ b/src/HDF.PInvoke.1.10/H5DLLImporter.cs @@ -186,8 +186,13 @@ internal class H5MacDllImporter : H5DLLImporter // However, to get the lib handle for the symbols, we need to "reopen" it using the correct path. public H5MacDllImporter(string libName) { + string filePath; var fileName = $"lib{libName}.dylib"; + var basePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + var localPath = Path.Combine(basePath, fileName); + var packagePath = Path.Combine(basePath, "..", "..", "runtimes", "osx-x64", "native", fileName); + var process = new Process { StartInfo = new ProcessStartInfo @@ -202,19 +207,22 @@ public H5MacDllImporter(string libName) process.Start(); - var filePath = process.StandardOutput.ReadToEnd() + var resolvedFilePath = process.StandardOutput.ReadToEnd() .Split('\n') .Where(line => line.Contains(fileName)) .FirstOrDefault()? .Split(' ') .LastOrDefault(); - if (filePath == null) + if (resolvedFilePath != null && File.Exists(resolvedFilePath)) + filePath = resolvedFilePath; + else if (File.Exists(localPath)) + filePath = localPath; + else if (File.Exists(packagePath)) + filePath = packagePath; + else throw new FileNotFoundException(fileName); - if (!File.Exists(filePath)) - throw new FileNotFoundException(filePath); - _handle = dlopen(filePath, RTLD_NOW); if (_handle == IntPtr.Zero)