Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions csharp/src/Microsoft.ML.OnnxRuntime/NativeMethods.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -866,13 +866,30 @@ static NativeMethods()
internal class NativeLib
{
#if __ANDROID__
// define the library name required for android
// Define the library name required for Android
internal const string DllName = "libonnxruntime.so";
#elif __IOS__
// define the library name required for iOS
// Define the library name required for iOS
internal const string DllName = "__Internal";
#else
internal const string DllName = "onnxruntime";
// For desktop platforms, explicitly specify the DLL name with extension to avoid
// issues on case-sensitive filesystems (including Windows with case-sensitivity enabled).
//
// Previous behavior relied on .NET automatically adding platform-specific extensions:
// Windows: onnxruntime -> onnxruntime.dll
// Linux: onnxruntime -> libonnxruntime.so
// macOS: onnxruntime -> libonnxruntime.dylib
//
// By specifying "onnxruntime.dll" explicitly, we ensure consistent behavior across
// case-sensitive and case-insensitive filesystems. This requires that native libraries
// for all platforms be named "onnxruntime.dll" in their respective runtime folders,
// or that appropriate symlinks/aliases be created during packaging.
//
// NuGet packages should contain:
// - runtimes/win-{arch}/native/onnxruntime.dll
// - runtimes/linux-{arch}/native/onnxruntime.dll (symlink to libonnxruntime.so)
Comment thread
snnn marked this conversation as resolved.
Outdated
// - runtimes/osx-{arch}/native/onnxruntime.dll (symlink to libonnxruntime.dylib)
internal const string DllName = "onnxruntime.dll";
#endif
}

Expand Down Expand Up @@ -2951,7 +2968,9 @@ internal static class OrtExtensionsNativeMethods
#elif __IOS__
internal const string ExtensionsDllName = "__Internal";
#else
internal const string ExtensionsDllName = "ortextensions";
// For desktop platforms, explicitly specify the DLL name with extension to avoid
// issues on case-sensitive filesystems. See NativeLib.DllName for detailed explanation.
internal const string ExtensionsDllName = "ortextensions.dll";
#endif

[DllImport(ExtensionsDllName, CharSet = CharSet.Ansi,
Expand Down
Loading