diff --git a/csharp/OnnxRuntime.CSharp.proj b/csharp/OnnxRuntime.CSharp.proj
index 95207d158affe..6779fd60bcd0a 100644
--- a/csharp/OnnxRuntime.CSharp.proj
+++ b/csharp/OnnxRuntime.CSharp.proj
@@ -64,13 +64,6 @@ CMake creates a target to this project
-
-
-
-
-
-
-
@@ -153,7 +146,7 @@ CMake creates a target to this project
$(BaseTargets);$(MobileTargets)
+
+
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+
+ $(ProjectDir)..\..\..
+
+
+ true
+
+
+
Microsoft.ML.OnnxRuntime
Microsoft.ML.OnnxRuntime
@@ -66,54 +93,31 @@
Commit: $(BUILD_SOURCEVERSION)
Build: https://aiinfra.visualstudio.com/Lotus/_build/results?buildId=$(BUILD_BUILDID)
+ README.md
+ LICENSE.txt
+
+
+ true
+
+ true
+ ..\..\OnnxRuntime.snk
+
+ $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb
+
AnyCPU;x86
default
true
- true
- ..\..\OnnxRuntime.snk
-
- $(ProjectDir)..\..\..
- $(OnnxRuntimeRoot)\csharp
x64
false
false
portable
-
- true
-
-
- true
-
-
-
-
- false
- $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb
Debug;Release;RelWithDebInfo
-
- true
- true
- true
-
-
- true
- true
- true
-
-
- $(OnnxRuntimeCsharpRoot)\..\build\Linux
- $(OnnxRuntimeBuildDirectory)\$(Configuration)
-
-
-
- $(OnnxRuntimeCsharpRoot)\..\build\Windows
$(OnnxRuntimeBuildDirectory)\$(Configuration)\$(Configuration)
-
-
-
- $(OnnxRuntimeCsharpRoot)\..\build\MacOS
+
$(OnnxRuntimeBuildDirectory)\$(Configuration)
-
+
$(OrtConstants);__MOBILE__
@@ -155,12 +148,12 @@
$(OrtConstants);__ANDROID__
-
+
$(OrtConstants);__IOS__
-
-
+
+
$(OrtConstants);__ENABLE_COREML__
@@ -178,128 +171,6 @@
$(DefineConstants);$(OrtConstants)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.Common/Microsoft.ML.OnnxRuntime.Tests.Common.csproj b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.Common/Microsoft.ML.OnnxRuntime.Tests.Common.csproj
index 60d18ad31e811..07ca7fe7c64bf 100644
--- a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.Common/Microsoft.ML.OnnxRuntime.Tests.Common.csproj
+++ b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.Common/Microsoft.ML.OnnxRuntime.Tests.Common.csproj
@@ -1,16 +1,19 @@
+
+ true
+ true
+ true
+
+ $(ProjectDir)..\..\..
+
netstandard2.0;net8.0
false
- $(ProjectDir)..\..
AnyCPU
bin\$(Configuration)\
- true
- true
- true
- $(OnnxRuntimeCsharpRoot)\..\cmake\external\onnx
+ $(OnnxRuntimeRoot)\cmake\external\onnx
8981
@@ -22,30 +25,22 @@
..\..\OnnxRuntime.snk
Debug;Release;RelWithDebInfo
+
Microsoft.ML.OnnxRuntime.Tests
Microsoft.ML.OnnxRuntime.Tests.Common
-
-
- $(OnnxRuntimeCsharpRoot)\..\build\Linux
- $(OnnxRuntimeBuildDirectory)\$(Configuration)
- $(OnnxRuntimeBuildDirectory)\$(Configuration)\external\protobuf\cmake
- $(ProtocDirectory)\protoc
-
-
-
- $(OnnxRuntimeCsharpRoot)\..\build\Windows
- $(OnnxRuntimeBuildDirectory)\$(Configuration)\$(Configuration)
$(OnnxRuntimeBuildDirectory)\$(Configuration)\external\protobuf\cmake\$(Configuration)
$(ProtocDirectory)\protoc.exe
+
+ $(OnnxRuntimeBuildDirectory)\$(Configuration)\external\protobuf\cmake
+ $(ProtocDirectory)\protoc
+
+
-
- $(OnnxRuntimeCsharpRoot)\..\build\MacOS
- $(OnnxRuntimeBuildDirectory)\$(Configuration)
$(OnnxRuntimeBuildDirectory)\$(Configuration)\external\protobuf\cmake
$(ProtocDirectory)\protoc
@@ -102,28 +97,6 @@
-
-
-
- PreserveNewest
- false
-
-
-
- PreserveNewest
- false
-
-
-
- PreserveNewest
- false
-
-
-
@@ -132,16 +105,20 @@
-
+
-
+
+
-
+
+
@@ -152,20 +129,20 @@
+
- TestData\%(Filename)%(Extension)
+ TestData\%(Filename)%(Extension)
-
- TestData\overridable_initializer.onnx
+
+ TestData\overridable_initializer.onnx
-
- TestData\capi_symbolic_dims.onnx
+
+ TestData\capi_symbolic_dims.onnx
-
diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.Common/NativeLibraryInclude.props b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.Common/NativeLibraryInclude.props
new file mode 100644
index 0000000000000..3daab21dbcbac
--- /dev/null
+++ b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.Common/NativeLibraryInclude.props
@@ -0,0 +1,171 @@
+
+
+
+
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+
+
+ false
+ 1.20.0-dev-20241007
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(OnnxRuntimeRoot)\build\Windows
+ $(OnnxRuntimeBuildDirectory)\$(Configuration)\$(Configuration)
+
+
+
+ $(OnnxRuntimeRoot)\build\Linux
+ $(OnnxRuntimeBuildDirectory)\$(Configuration)
+
+
+
+ $(OnnxRuntimeRoot)\build\MacOS
+ $(OnnxRuntimeBuildDirectory)\$(Configuration)
+
+
+
+ $(OnnxRuntimeRoot)\build\Android
+ $(OnnxRuntimeBuildDirectory)\$(Configuration)
+
+
+
+ $(OnnxRuntimeRoot)\build\iOS
+ iPhoneSimulator
+ $(Platform.ToLower())
+ $(OnnxRuntimeBuildDirectory)\$(Configuration)\$(Configuration)-$(PlatformLower)
+
+
+
+ $(OnnxRuntimeRoot)\build\macOS
+ $(OnnxRuntimeBuildDirectory)\$(Configuration)
+
+
+
+
+ PreserveNewest
+ true
+
+
+
+
+
+ PreserveNewest
+ false
+
+
+
+
+
+ PreserveNewest
+ false
+
+
+
+
+
+ libs\libonnxruntime.so
+
+
+
+
+
+ libs\libonnxruntime.dylib
+ Dynamic
+ True
+ True
+
+
+
+
+
+ libs\libonnxruntime.dylib
+ Dynamic
+ True
+ True
+
+
+
+
+
+
+
+
+ false
+ true
+ false
+ true
+ false
+ true
+
+
+
+
+
+
+
+
+
+
+
diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.Common/Tensors/TensorTests.cs b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.Common/Tensors/TensorTests.cs
index 27cde1dbe9ed8..46dd292e8514e 100644
--- a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.Common/Tensors/TensorTests.cs
+++ b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.Common/Tensors/TensorTests.cs
@@ -2180,10 +2180,13 @@ public void GetArrayString(TensorConstructor constructor)
{22,23}
}
}";
+ // remove \r so the newlines are just \n on all platforms
+ expected = expected.Replace("\r", "");
+ var actual= tensor.GetArrayString().Replace("\r", "");
- Assert.Equal(expected, tensor.GetArrayString());
+ Assert.Equal(expected, actual);
- var expectedNoSpace = expected.Replace(Environment.NewLine, "").Replace(" ", "");
+ var expectedNoSpace = expected.Replace("\n", "").Replace(" ", "");
Assert.Equal(expectedNoSpace, tensor.GetArrayString(false));
}
diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.MAUI/Microsoft.ML.OnnxRuntime.Tests.MAUI.csproj b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.MAUI/Microsoft.ML.OnnxRuntime.Tests.MAUI.csproj
index 210a04d78f107..e07448daeea7f 100644
--- a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.MAUI/Microsoft.ML.OnnxRuntime.Tests.MAUI.csproj
+++ b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.MAUI/Microsoft.ML.OnnxRuntime.Tests.MAUI.csproj
@@ -1,306 +1,125 @@
-
-
- true
- true
- true
- true
- $(ProjectDir)..\..\..
-
-
-
-
- net8.0-android;net8.0-ios;net8.0-maccatalyst
- $(TargetFrameworks);net8.0-windows10.0.19041.0
-
-
-
-
- Exe
- Microsoft.ML.OnnxRuntime.Tests.MAUI
- true
- true
- enable
- enable
- true
-
- 8002
-
-
- $(DefineConstants);INCLUDE_FAILING_TESTS
- $(DefineConstants);MODE_NON_INTERACTIVE_VISUAL
- $(DefineConstants);MODE_XHARNESS
-
-
- Microsoft.ML.OnnxRuntime.Tests.MAUI
-
-
- ORT.CSharp.Tests.MAUI
-
-
- 1.0
- 1
-
- 15.0
- 13.1
- 30.0
- 10.0.17763.0
- 10.0.17763.0
-
- true
- ..\..\OnnxRuntime.snk
-
-
- false
-
-
-
-
- $(OnnxRuntimeRoot)\build\microsoft.ml.onnxruntime.1.18.1\runtimes
-
- true
-
-
-
- $(OnnxRuntimeRoot)\build\Windows
- $(OnnxRuntimeBuildDirectory)\$(Configuration)\$(Configuration)
-
- $(PrebuiltRuntimesDir)\win-x64\native
-
-
- $(OnnxRuntimeRoot)\build\Android
- $(OnnxRuntimeBuildDirectory)\$(Configuration)
- $(PrebuiltRuntimesDir)\android\native\onnxruntime.aar
-
-
- $(OnnxRuntimeRoot)\build\iOS
- iPhoneSimulator
- $(Platform.ToLower())
- $(OnnxRuntimeBuildDirectory)\$(Configuration)\$(Configuration)-$(PlatformLower)
- $(PrebuiltRuntimesDir)\ios\native\onnxruntime.xcframework
-
-
- $(OnnxRuntimeRoot)\build\macOS
- $(OnnxRuntimeBuildDirectory)\$(Configuration)
- $(PrebuiltRuntimesDir)\ios\native\onnxruntime.xcframework
-
-
-
-
-
- PreserveNewest
- true
-
-
-
-
- PreserveNewest
- true
-
-
-
-
- PreserveNewest
- false
-
-
- PreserveNewest
- false
-
-
- PreserveNewest
- false
-
-
- PreserveNewest
- false
-
-
- PreserveNewest
- false
-
-
- PreserveNewest
- false
-
-
-
-
-
-
- libs\libonnxruntime.so
-
-
-
-
-
-
-
-
-
- libs\libonnxruntime.dylib
- Dynamic
- True
- True
-
-
-
-
- Framework
- True
- True
-
-
-
-
-
-
- libs\libonnxruntime.dylib
- Dynamic
- True
- True
-
-
-
-
- Framework
- True
- True
-
-
-
-
-
-
- false
- true
- false
- true
- false
- true
-
- false
- true
- false
- true
- false
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- InferenceTest.cs
-
-
- OrtIoBindingAllocationTest.cs
-
-
- TensorTests.cs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <_VisualStudioTestRunnerFiles Include="@(PackagingOutputs)" Condition="$([System.String]::Copy('%(PackagingOutputs.FullPath)').Contains('xunit.runner.visualstudio'))" />
-
-
-
+
+ $(ProjectDir)..\..\..
+
+
+
+
+
+
+ net8.0-android;net8.0-ios;net8.0-maccatalyst
+ $(TargetFrameworks);net8.0-windows10.0.19041.0
+
+
+
+
+ Exe
+ Microsoft.ML.OnnxRuntime.Tests.MAUI
+ true
+ true
+ enable
+ enable
+ true
+
+ 8002
+
+
+ $(DefineConstants);INCLUDE_FAILING_TESTS
+ $(DefineConstants);MODE_NON_INTERACTIVE_VISUAL
+ $(DefineConstants);MODE_XHARNESS
+
+
+ Microsoft.ML.OnnxRuntime.Tests.MAUI
+
+
+ ORT.CSharp.Tests.MAUI
+
+
+ 1.0
+ 1
+
+ 15.0
+ 13.1
+ 30.0
+ 10.0.17763.0
+ 10.0.17763.0
+
+ true
+ ..\..\OnnxRuntime.snk
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ InferenceTest.cs
+
+
+ OrtIoBindingAllocationTest.cs
+
+
+ TensorTests.cs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <_VisualStudioTestRunnerFiles
+ Include="@(PackagingOutputs)"
+ Condition="$([System.String]::Copy('%(PackagingOutputs.FullPath)').Contains('xunit.runner.visualstudio'))" />
+
+
+
diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.MAUI/ReadMe.md b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.MAUI/ReadMe.md
new file mode 100644
index 0000000000000..07cb5fe7c9b3d
--- /dev/null
+++ b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.MAUI/ReadMe.md
@@ -0,0 +1,9 @@
+The MAUI test project can be optionally used with a pre-built ONNX Runtime native nuget package (Microsoft.ML.OnnxRuntime).
+
+To do so, specify the `UsePrebuiltNativePackage` and `CurrentOnnxRuntimeVersion` properties when building the project. These can be set via the command-line or as environment variables.
+
+For example:
+
+```cmd
+dotnet build csharp\test\Microsoft.ML.OnnxRuntime.Tests.MAUI\Microsoft.ML.OnnxRuntime.Tests.MAUI.csproj --property:UsePrebuiltNativePackage=true --property:CurrentOnnxRuntimeVersion=1.19.2 --source directory_containing_native_nuget_package --source https://api.nuget.org/v3/index.json
+```
diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.NetCoreApp/Microsoft.ML.OnnxRuntime.Tests.NetCoreApp.csproj b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.NetCoreApp/Microsoft.ML.OnnxRuntime.Tests.NetCoreApp.csproj
index b822c999e4d39..a8abcd2b4aa1c 100644
--- a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.NetCoreApp/Microsoft.ML.OnnxRuntime.Tests.NetCoreApp.csproj
+++ b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.NetCoreApp/Microsoft.ML.OnnxRuntime.Tests.NetCoreApp.csproj
@@ -1,4 +1,9 @@
+
+ $(ProjectDir)..\..\..
+
+
+
net8.0
@@ -6,9 +11,7 @@
$(ProjectDir)..\..
AnyCPU;x86
bin\$(Configuration)\
- true
- true
- true
+
$(OnnxSourceDirectory)\onnx
default
@@ -35,19 +38,19 @@
- $(OnnxRuntimeCsharpRoot)\..\build\Linux
+ $(OnnxRuntimeRoot)\build\Linux
$(OnnxRuntimeBuildDirectory)\$(Configuration)
- $(OnnxRuntimeCsharpRoot)\..\build\Windows
+ $(OnnxRuntimeRoot)\build\Windows
$(OnnxRuntimeBuildDirectory)\$(Configuration)\$(Configuration)
- $(OnnxRuntimeCsharpRoot)\..\build\MacOS
+ $(OnnxRuntimeRoot)\build\MacOS
$(OnnxRuntimeBuildDirectory)\$(Configuration)
@@ -58,15 +61,14 @@
PreserveNewest
@@ -74,45 +76,39 @@
PreserveNewest
false
PreserveNewest
false
-
- PreserveNewest
- false
-
-
+
PreserveNewest
false
-
- PreserveNewest
- false
-
-
+
+
PreserveNewest
false
-
+
+
PreserveNewest
false
-
+
+
PreserveNewest
false
+
@@ -131,7 +127,7 @@
-
+
PreserveNewest
false