From a11ba732c5b8a810f796b1a52641b7a211611f3c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 27 Oct 2025 16:50:10 +0000 Subject: [PATCH 1/3] Initial plan From 0167fa9ff5b9ec2ec5e65d4676816b47539c9e99 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 27 Oct 2025 17:16:59 +0000 Subject: [PATCH 2/3] Specify explicit DLL extensions in DllImport to fix case-sensitive filesystem issues Co-authored-by: snnn <856316+snnn@users.noreply.github.com> --- .../NativeMethods.shared.cs | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/csharp/src/Microsoft.ML.OnnxRuntime/NativeMethods.shared.cs b/csharp/src/Microsoft.ML.OnnxRuntime/NativeMethods.shared.cs index b97adfbd564d5..d92a1d1fe0997 100644 --- a/csharp/src/Microsoft.ML.OnnxRuntime/NativeMethods.shared.cs +++ b/csharp/src/Microsoft.ML.OnnxRuntime/NativeMethods.shared.cs @@ -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) + // - runtimes/osx-{arch}/native/onnxruntime.dll (symlink to libonnxruntime.dylib) + internal const string DllName = "onnxruntime.dll"; #endif } @@ -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, From d04250209b8a8645fb8ff82f92fd0aa8ed5f7632 Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Mon, 3 Nov 2025 18:04:01 -0800 Subject: [PATCH 3/3] Update NativeMethods.shared.cs --- .../NativeMethods.shared.cs | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/csharp/src/Microsoft.ML.OnnxRuntime/NativeMethods.shared.cs b/csharp/src/Microsoft.ML.OnnxRuntime/NativeMethods.shared.cs index d92a1d1fe0997..1ae7b5c9eb991 100644 --- a/csharp/src/Microsoft.ML.OnnxRuntime/NativeMethods.shared.cs +++ b/csharp/src/Microsoft.ML.OnnxRuntime/NativeMethods.shared.cs @@ -872,23 +872,7 @@ internal class NativeLib // Define the library name required for iOS internal const string DllName = "__Internal"; #else - // 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) - // - runtimes/osx-{arch}/native/onnxruntime.dll (symlink to libonnxruntime.dylib) + // Note: the file name in ONNX Runtime nuget package must be onnxruntime.dll instead of onnxruntime.DLL(Windows filesystem can be case sensitive) internal const string DllName = "onnxruntime.dll"; #endif }