From e6abde022e893d0833fed15d58edb9a913a86273 Mon Sep 17 00:00:00 2001 From: carzh Date: Tue, 28 Jan 2025 14:42:42 -0800 Subject: [PATCH 01/27] Reapply "[Mobile] Add BrowserStack Android MAUI Test (#23383)" (#23474) This reverts commit d00ae325cea6b7032493c4459061c53c5a2b43d9. --- .../.config/dotnet-tools.json | 13 ++ .../BrowserStackTest.cs | 68 ++++++ ...xRuntime.Tests.BrowserStack.Android.csproj | 22 ++ .../README.md | 48 ++++ .../RunAllTest.cs | 123 ++++++++++ .../browserstack.yml | 13 ++ ...Microsoft.ML.OnnxRuntime.Tests.MAUI.csproj | 220 +++++++++--------- 7 files changed, 400 insertions(+), 107 deletions(-) create mode 100644 csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/.config/dotnet-tools.json create mode 100644 csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/BrowserStackTest.cs create mode 100644 csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android.csproj create mode 100644 csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/README.md create mode 100644 csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/RunAllTest.cs create mode 100644 csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/browserstack.yml diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/.config/dotnet-tools.json b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/.config/dotnet-tools.json new file mode 100644 index 0000000000000..67d39c423d4d7 --- /dev/null +++ b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/.config/dotnet-tools.json @@ -0,0 +1,13 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "browserstack-sdk": { + "version": "1.16.13", + "commands": [ + "browserstack-sdk" + ], + "rollForward": false + } + } +} \ No newline at end of file diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/BrowserStackTest.cs b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/BrowserStackTest.cs new file mode 100644 index 0000000000000..84377d65d1213 --- /dev/null +++ b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/BrowserStackTest.cs @@ -0,0 +1,68 @@ +using Newtonsoft.Json; +using NUnit.Framework.Interfaces; +using NUnit.Framework; +using OpenQA.Selenium; +using OpenQA.Selenium.Appium; +using OpenQA.Selenium.Appium.Android; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android +{ + public class BrowserStackTest + { + public AndroidDriver driver; + public BrowserStackTest() + {} + + [SetUp] + public void Init() + { + var androidOptions = new AppiumOptions { + AutomationName = "UIAutomator2", + PlatformName = "Android", + }; + + driver = new AndroidDriver(new Uri("http://127.0.0.1:4723/wd/hub"), androidOptions); + } + + /// + /// Passes the correct test status to BrowserStack and ensures the driver quits. + /// + [TearDown] + public void Dispose() + { + try + { + // According to + // https://www.browserstack.com/docs/app-automate/appium/set-up-tests/mark-tests-as-pass-fail + // BrowserStack doesn't know whether test assertions have passed or failed. Below handles + // passing the test status to BrowserStack along with any relevant information. + if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Failed) + { + String failureMessage = TestContext.CurrentContext.Result.Message; + String jsonToSendFailure = + String.Format("browserstack_executor: {\"action\": \"setSessionStatus\", \"arguments\": " + + "{\"status\":\"failed\", \"reason\": {0}}}", + JsonConvert.ToString(failureMessage)); + + ((IJavaScriptExecutor)driver).ExecuteScript(jsonToSendFailure); + } + else + { + ((IJavaScriptExecutor)driver) + .ExecuteScript("browserstack_executor: {\"action\": \"setSessionStatus\", \"arguments\": " + + "{\"status\":\"passed\", \"reason\": \"\"}}"); + } + } + finally + { + // will run even if exception is thrown by previous block + ((AndroidDriver)driver).Quit(); + } + } + } +} diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android.csproj b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android.csproj new file mode 100644 index 0000000000000..9b9028d30cc5b --- /dev/null +++ b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android.csproj @@ -0,0 +1,22 @@ + + + + net8.0 + enable + enable + + false + true + + + + + + + + + + + + + diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/README.md b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/README.md new file mode 100644 index 0000000000000..9c4e2307d8f70 --- /dev/null +++ b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/README.md @@ -0,0 +1,48 @@ +# BrowserStack Android test +This project will run the Android MAUI tests on BrowserStack, which allows you to run automated tests on a variety of mobile devices. + +## Context +Microsoft.ML.OnnxRuntime.Tests.MAUI uses DeviceRunners.VisualRunners to allow running the unit tests (found in Microsoft.ML.OnnxRuntime.Tests.Common) across multiple devices. DeviceRunners.VisualRunners provides a simple UI with a button that will run the unit tests and a panel with the unit test results. + +In order to automate the process of running the unit tests across mobile devices, Appium is used for UI testing orchestration (it provides a way to interact with the UI), and BrowserStack automatically runs these Appium tests across different mobile devices. + +This project does not include the capability to start an Appium server locally or attach to a local emulator or device. + +## Build & run instructions +### Requirements +* A BrowserStack account with access to App Automate + * You can set BrowserStack credentials as environment variables as shown [here](https://www.browserstack.com/docs/app-automate/appium/getting-started/c-sharp/nunit/integrate-your-tests#CLI) +* ONNXRuntime NuGet package + 1. You can either download the [stable NuGet package](https://www.nuget.org/packages/Microsoft.ML.OnnxRuntime) then follow the instructions from [NativeLibraryInclude.props file](../Microsoft.ML.OnnxRuntime.Tests.Common/NativeLibraryInclude.props) to use the downloaded .nupkg file + 2. Or follow the [build instructions](https://onnxruntime.ai/docs/build/android.html) to build the Android package locally +* The dotnet workloads for maui and maui-android, which will not always automatically install correctly + 1. `dotnet workload install maui` + 2. `dotnet workload install maui-android` +* [Appium](https://appium.io/docs/en/latest/quickstart/) and the [UiAutomator2 driver](https://appium.io/docs/en/latest/quickstart/uiauto2-driver/) + +### Run instructions +1. Build the Microsoft.ML.OnnxRuntime.Tests.MAUI project into a signed APK. + 1. Run the following: `dotnet publish -c Release -f net8.0-android` in the Microsoft.ML.OnnxRuntime.Tests.MAUI directory. + 2. Search for the APK files generated. They should be located in `bin\Release\net8.0-android\publish`. + 3. If they're in a different location, edit the `browserstack.yml` file to target the path to the signed APK. +2. Ensure you've set the BrowserStack credentials as environment variables. +3. Run the following in the Microsoft.ML.OnnxRuntime.Tests.Android.BrowserStack directory: `dotnet test` +4. Navigate to the [BrowserStack App Automate dashboard](https://app-automate.browserstack.com/dashboard/v2/builds) to see your test running! + +## Troubleshooting & Resources +### BrowserStack Resources +- [Configuration docs](https://www.browserstack.com/docs/app-automate/appium/sdk-params#test-context) for browserstack.yml +- [Configuration generator](https://www.browserstack.com/docs/app-automate/capabilities) for browserstack.yml +- [Integration guide](https://www.browserstack.com/docs/app-automate/appium/getting-started/c-sharp/nunit/integrate-your-tests#CLI) + +### Troubleshooting +- Issues building the MAUI app: + - Make sure that the maui and maui-android workloads are installed correctly by running `dotnet workload list` + - If you believe the issues are workload related, you can also try running `dotnet workload repair` (this has personally never worked for me) + - Try running `dotnet clean`. However, this does not fully remove all the previous intermediaries. If you're still running into the errors, manually deleting the bin and obj folders can sometimes resolve them. +- After building the MAUI app, try installing on an emulator and clicking the "Run All" button to ensure that everything is working. (If you are missing the ONNXRuntime package, it will not show up as an error until you click "Run All".) + - Running the MAUI app from Visual Studio will not replicate running it through BrowserStack. Instead, use `adb install [path to signed apk]` to install the app then use the emulator to launch the app. +- Issues with the Android.BrowserStack test app: there is an Appium Doctor package on npm -- run `npm install @appium/doctor --location=global` then `appium-doctor --android` and follow the directed instructions. Some errors with Appium on Android will not appear until runtime. +- Connection refused by Appium server: this can happen if you already have an Appium server running locally. If you do, stop the Appium server then try `dotnet test` again. +- App is crashing on BrowserStack or it emits an error that it cannot run this APK file: make sure that you are passing in the correct signed APK from the publish folder. +- It appears that a test runs on CLI but a build is not launched on BrowserStack: this happens when the BrowserStack Test Adapter cannot find the browserstack.yml file (which has to be named "browserstack.yml" -- do not be tricked by BrowserStack's article on custom-named configuration files) diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/RunAllTest.cs b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/RunAllTest.cs new file mode 100644 index 0000000000000..5db3dc9957d1c --- /dev/null +++ b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/RunAllTest.cs @@ -0,0 +1,123 @@ +using OpenQA.Selenium.Appium; +using OpenQA.Selenium; +using NUnit.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android +{ + /// + /// This class contains a single test: RunAll, which interacts with the UI from + /// https://github.com/mattleibow/DeviceRunners/tree/main by clicking the "Run All" button and checking the number + /// of passed and failed tests. + /// + /// It searches for elements on the page using Appium's WebDriver. These searches use the XPath attributes. + /// + /// Launching the MAUI test app in Appium Inspector will allow you to see the exact XPath attributes for each + /// element. + /// + [TestFixture] + public class RunAllTest : BrowserStackTest + { + public AppiumElement FindAppiumElement(String xpathQuery, String text) + { + IReadOnlyCollection appiumElements = driver.FindElements(By.XPath(xpathQuery)); + + foreach (var element in appiumElements) + { + if (element.Text.Contains(text)) + { + return element; + } + } + // was unable to find given element + throw new Exception(String.Format("Could not find {0}: {1} on the page.", xpathQuery, text)); + } + + public AppiumElement FindAppiumElementThenClick(String xpathQuery, String text) + { + AppiumElement appiumElement = FindAppiumElement(xpathQuery, text); + appiumElement.Click(); + return appiumElement; + } + + public (int, int) GetPassFailCount() + { + int numPassed = -1; + int numFailed = -1; + + IReadOnlyCollection labelElements = + driver.FindElements(By.XPath("//android.widget.TextView")); + + for (int i = 0; i < labelElements.Count; i++) + { + AppiumElement element = labelElements.ElementAt(i); + + if (element.Text.Equals("✔")) + { + i++; + numPassed = int.Parse(labelElements.ElementAt(i).Text); + } + + if (element.Text.Equals("⛔")) + { + i++; + numFailed = int.Parse(labelElements.ElementAt(i).Text); + break; + } + } + + Assert.That(numPassed, Is.GreaterThanOrEqualTo(0), "Could not find number passed label."); + Assert.That(numFailed, Is.GreaterThanOrEqualTo(0), "Could not find number failed label."); + + return (numPassed, numFailed); + } + + [Test] + public async Task ClickRunAllTest() + { + // XAML for the main page: + // https://github.com/mattleibow/DeviceRunners/blob/cba7644e07b305ba64dc930b01c3eee55ef2b93d/src/DeviceRunners.VisualRunners.Maui/App/Pages/HomePage.xaml + AppiumElement runAllButton = FindAppiumElementThenClick("//android.widget.Button", "Run All"); + + while (!runAllButton.Enabled) + { + // waiting for unit tests to execute + await Task.Delay(500); + } + + var (numPassed, numFailed) = GetPassFailCount(); + + if (numFailed == 0) + { + return; + } + + // click into test results if tests have failed + FindAppiumElementThenClick("//android.widget.TextView", "⛔"); + await Task.Delay(500); + + // Brings you to the test assembly page + // XAML for test assembly page: + // https://github.com/mattleibow/DeviceRunners/blob/cba7644e07b305ba64dc930b01c3eee55ef2b93d/src/DeviceRunners.VisualRunners.Maui/App/Pages/TestAssemblyPage.xaml + FindAppiumElementThenClick("//android.widget.EditText", "All"); + await Task.Delay(100); + FindAppiumElementThenClick("//android.widget.TextView", "Failed"); + await Task.Delay(500); + + StringBuilder sb = new StringBuilder(); + sb.AppendLine("PASSED TESTS: " + numPassed + " | FAILED TESTS: " + numFailed); + + IReadOnlyCollection textResults = driver.FindElements(By.XPath("//android.widget.TextView")); + foreach (var element in textResults) + { + sb.AppendLine(element.Text); + } + + Assert.That(numFailed, Is.EqualTo(0), sb.ToString()); + } + } +} diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/browserstack.yml b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/browserstack.yml new file mode 100644 index 0000000000000..9efbc9fc6aa61 --- /dev/null +++ b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/browserstack.yml @@ -0,0 +1,13 @@ +app: ..\Microsoft.ML.OnnxRuntime.Tests.MAUI\bin\Release\net8.0-android\publish\ORT.CSharp.Tests.MAUI-Signed.apk +platforms: + - platformName: android + deviceName: Samsung Galaxy S22 Ultra + platformVersion: 12.0 +browserstackLocal: true +buildName: ORT android test +buildIdentifier: ${BUILD_NUMBER} +projectName: ORT-UITests +debug: true +networkLogs: false +testContextOptions: + skipSessionStatus: true \ No newline at end of file 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 e07448daeea7f..652da8899f6a9 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,125 +1,131 @@  - - $(ProjectDir)..\..\.. - + + $(ProjectDir)..\..\.. + - + - - - net8.0-android;net8.0-ios;net8.0-maccatalyst - $(TargetFrameworks);net8.0-windows10.0.19041.0 + + + 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 - - - - - - - - - - - - - - - - - - - - - + + 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 - - - - - + + InferenceTest.cs + + + OrtIoBindingAllocationTest.cs + + + TensorTests.cs + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - <_VisualStudioTestRunnerFiles + + + + + + + + + + + + + + + + + + + + + + + + <_VisualStudioTestRunnerFiles Include="@(PackagingOutputs)" Condition="$([System.String]::Copy('%(PackagingOutputs.FullPath)').Contains('xunit.runner.visualstudio'))" /> - - - + + + + + + false + en + + From 0dd42e9710fc78886dc8cfa1d17f8d052b8669d4 Mon Sep 17 00:00:00 2001 From: carzh Date: Wed, 29 Jan 2025 15:00:29 -0800 Subject: [PATCH 02/27] maui csproj that builds into apk successfully --- ...Microsoft.ML.OnnxRuntime.Tests.MAUI.csproj | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) 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 652da8899f6a9..638e4a95fcaf9 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 @@ -17,6 +17,7 @@ either BOTH runtimes must be indicated or ONLY macatalyst-x64. --> + Exe Microsoft.ML.OnnxRuntime.Tests.MAUI true true @@ -84,15 +85,9 @@ - - - + + + @@ -116,16 +111,22 @@ - <_VisualStudioTestRunnerFiles - Include="@(PackagingOutputs)" - Condition="$([System.String]::Copy('%(PackagingOutputs.FullPath)').Contains('xunit.runner.visualstudio'))" /> + <_VisualStudioTestRunnerFiles Include="@(PackagingOutputs)" Condition="$([System.String]::Copy('%(PackagingOutputs.FullPath)').Contains('xunit.runner.visualstudio'))" /> + + + + false en + + apk + + From 4011a108e05af9e3f604c61cc33690855e88c4f7 Mon Sep 17 00:00:00 2001 From: carzh Date: Wed, 29 Jan 2025 15:13:25 -0800 Subject: [PATCH 03/27] attempt to fix nuget pipeline failure --- tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml b/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml index 1ab4fd2a8e9e7..b34ff649fb592 100644 --- a/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml +++ b/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml @@ -446,7 +446,7 @@ stages: solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.sln' platform: 'Any CPU' configuration: RelWithDebInfo - msbuildArguments: '-p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=$(OrtPackageId) -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix) -p:PackageVersion=$(OnnxRuntimeVersion)' + msbuildArguments: '-p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=$(OrtPackageId) -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix) -p:PackageVersion=$(OnnxRuntimeVersion) -target:Microsoft.ML.OnnxRuntime;Microsoft.ML.OnnxRuntime.PerfTool' workingDirectory: '$(Build.SourcesDirectory)\csharp' - ${{ if eq(parameters.DoEsrp, true) }}: From 0783bb18b17c53146b68ab1a51f8c4e3dd7a102e Mon Sep 17 00:00:00 2001 From: carzh Date: Thu, 30 Jan 2025 11:29:51 -0800 Subject: [PATCH 04/27] target only ort for building c# bindings --- tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml b/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml index b34ff649fb592..4ccf94b00e261 100644 --- a/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml +++ b/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml @@ -446,7 +446,7 @@ stages: solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.sln' platform: 'Any CPU' configuration: RelWithDebInfo - msbuildArguments: '-p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=$(OrtPackageId) -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix) -p:PackageVersion=$(OnnxRuntimeVersion) -target:Microsoft.ML.OnnxRuntime;Microsoft.ML.OnnxRuntime.PerfTool' + msbuildArguments: '-p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=$(OrtPackageId) -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix) -p:PackageVersion=$(OnnxRuntimeVersion) -target:Microsoft.ML.OnnxRuntime' workingDirectory: '$(Build.SourcesDirectory)\csharp' - ${{ if eq(parameters.DoEsrp, true) }}: From 5a5fe4ba4ff8310f9ee50fdfb0b2daec237de37a Mon Sep 17 00:00:00 2001 From: carzh Date: Thu, 30 Jan 2025 17:52:22 -0800 Subject: [PATCH 05/27] removed test projects from sln and updated pipeline yml --- csharp/OnnxRuntime.CSharp.sln | 7 ------- .../github/azure-pipelines/templates/c-api-cpu.yml | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/csharp/OnnxRuntime.CSharp.sln b/csharp/OnnxRuntime.CSharp.sln index 4556be2aa2b02..ed87fcb9e17d6 100644 --- a/csharp/OnnxRuntime.CSharp.sln +++ b/csharp/OnnxRuntime.CSharp.sln @@ -89,7 +89,6 @@ Global {2E295930-42B1-422D-925D-F07947AD8EFF}.Release|x86.ActiveCfg = Release|Any CPU {2E295930-42B1-422D-925D-F07947AD8EFF}.Release|x86.Build.0 = Release|Any CPU {2E295930-42B1-422D-925D-F07947AD8EFF}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU - {2E295930-42B1-422D-925D-F07947AD8EFF}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU {2E295930-42B1-422D-925D-F07947AD8EFF}.RelWithDebInfo|iPhone.ActiveCfg = Release|Any CPU {2E295930-42B1-422D-925D-F07947AD8EFF}.RelWithDebInfo|iPhone.Build.0 = Release|Any CPU {2E295930-42B1-422D-925D-F07947AD8EFF}.RelWithDebInfo|iPhoneSimulator.ActiveCfg = Release|Any CPU @@ -121,7 +120,6 @@ Global {037242E4-7C79-401F-A19C-6824B1BB356F}.Release|x86.Build.0 = Release|Any CPU {037242E4-7C79-401F-A19C-6824B1BB356F}.Release|x86.Deploy.0 = Release|Any CPU {037242E4-7C79-401F-A19C-6824B1BB356F}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU - {037242E4-7C79-401F-A19C-6824B1BB356F}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU {037242E4-7C79-401F-A19C-6824B1BB356F}.RelWithDebInfo|Any CPU.Deploy.0 = Release|Any CPU {037242E4-7C79-401F-A19C-6824B1BB356F}.RelWithDebInfo|iPhone.ActiveCfg = Release|Any CPU {037242E4-7C79-401F-A19C-6824B1BB356F}.RelWithDebInfo|iPhone.Build.0 = Release|Any CPU @@ -149,7 +147,6 @@ Global {1AA14958-9246-4163-9403-F650E65ADCBC}.Release|x86.ActiveCfg = Release|x86 {1AA14958-9246-4163-9403-F650E65ADCBC}.Release|x86.Build.0 = Release|x86 {1AA14958-9246-4163-9403-F650E65ADCBC}.RelWithDebInfo|Any CPU.ActiveCfg = RelWithDebInfo|Any CPU - {1AA14958-9246-4163-9403-F650E65ADCBC}.RelWithDebInfo|Any CPU.Build.0 = RelWithDebInfo|Any CPU {1AA14958-9246-4163-9403-F650E65ADCBC}.RelWithDebInfo|iPhone.ActiveCfg = RelWithDebInfo|Any CPU {1AA14958-9246-4163-9403-F650E65ADCBC}.RelWithDebInfo|iPhone.Build.0 = RelWithDebInfo|Any CPU {1AA14958-9246-4163-9403-F650E65ADCBC}.RelWithDebInfo|iPhoneSimulator.ActiveCfg = RelWithDebInfo|Any CPU @@ -197,7 +194,6 @@ Global {04FA49F0-AA23-4EE5-B455-6E12FFAD29E6}.Release|x86.ActiveCfg = Release|x86 {04FA49F0-AA23-4EE5-B455-6E12FFAD29E6}.Release|x86.Build.0 = Release|x86 {04FA49F0-AA23-4EE5-B455-6E12FFAD29E6}.RelWithDebInfo|Any CPU.ActiveCfg = RelWithDebInfo|Any CPU - {04FA49F0-AA23-4EE5-B455-6E12FFAD29E6}.RelWithDebInfo|Any CPU.Build.0 = RelWithDebInfo|Any CPU {04FA49F0-AA23-4EE5-B455-6E12FFAD29E6}.RelWithDebInfo|iPhone.ActiveCfg = RelWithDebInfo|Any CPU {04FA49F0-AA23-4EE5-B455-6E12FFAD29E6}.RelWithDebInfo|iPhone.Build.0 = RelWithDebInfo|Any CPU {04FA49F0-AA23-4EE5-B455-6E12FFAD29E6}.RelWithDebInfo|iPhoneSimulator.ActiveCfg = RelWithDebInfo|Any CPU @@ -221,7 +217,6 @@ Global {50173D13-DF29-42E7-A30B-8B12D36C77B1}.Release|x86.ActiveCfg = Release|x86 {50173D13-DF29-42E7-A30B-8B12D36C77B1}.Release|x86.Build.0 = Release|x86 {50173D13-DF29-42E7-A30B-8B12D36C77B1}.RelWithDebInfo|Any CPU.ActiveCfg = RelWithDebInfo|Any CPU - {50173D13-DF29-42E7-A30B-8B12D36C77B1}.RelWithDebInfo|Any CPU.Build.0 = RelWithDebInfo|Any CPU {50173D13-DF29-42E7-A30B-8B12D36C77B1}.RelWithDebInfo|iPhone.ActiveCfg = RelWithDebInfo|Any CPU {50173D13-DF29-42E7-A30B-8B12D36C77B1}.RelWithDebInfo|iPhone.Build.0 = RelWithDebInfo|Any CPU {50173D13-DF29-42E7-A30B-8B12D36C77B1}.RelWithDebInfo|iPhoneSimulator.ActiveCfg = RelWithDebInfo|Any CPU @@ -245,7 +240,6 @@ Global {30431891-3929-4394-8049-75055B92315F}.Release|x86.ActiveCfg = Release|Any CPU {30431891-3929-4394-8049-75055B92315F}.Release|x86.Build.0 = Release|Any CPU {30431891-3929-4394-8049-75055B92315F}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU - {30431891-3929-4394-8049-75055B92315F}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU {30431891-3929-4394-8049-75055B92315F}.RelWithDebInfo|iPhone.ActiveCfg = Release|Any CPU {30431891-3929-4394-8049-75055B92315F}.RelWithDebInfo|iPhone.Build.0 = Release|Any CPU {30431891-3929-4394-8049-75055B92315F}.RelWithDebInfo|iPhoneSimulator.ActiveCfg = Release|Any CPU @@ -301,7 +295,6 @@ Global {85E4F8C9-366A-4769-8DBC-ABCDE37FD460}.Release|x86.Build.0 = Release|Any CPU {85E4F8C9-366A-4769-8DBC-ABCDE37FD460}.Release|x86.Deploy.0 = Release|Any CPU {85E4F8C9-366A-4769-8DBC-ABCDE37FD460}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU - {85E4F8C9-366A-4769-8DBC-ABCDE37FD460}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU {85E4F8C9-366A-4769-8DBC-ABCDE37FD460}.RelWithDebInfo|Any CPU.Deploy.0 = Release|Any CPU {85E4F8C9-366A-4769-8DBC-ABCDE37FD460}.RelWithDebInfo|iPhone.ActiveCfg = Release|Any CPU {85E4F8C9-366A-4769-8DBC-ABCDE37FD460}.RelWithDebInfo|iPhone.Build.0 = Release|Any CPU diff --git a/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml b/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml index 4ccf94b00e261..1ab4fd2a8e9e7 100644 --- a/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml +++ b/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml @@ -446,7 +446,7 @@ stages: solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.sln' platform: 'Any CPU' configuration: RelWithDebInfo - msbuildArguments: '-p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=$(OrtPackageId) -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix) -p:PackageVersion=$(OnnxRuntimeVersion) -target:Microsoft.ML.OnnxRuntime' + msbuildArguments: '-p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=$(OrtPackageId) -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix) -p:PackageVersion=$(OnnxRuntimeVersion)' workingDirectory: '$(Build.SourcesDirectory)\csharp' - ${{ if eq(parameters.DoEsrp, true) }}: From 70e3a2362a8e1269298570291400f24492a612b5 Mon Sep 17 00:00:00 2001 From: carzh Date: Thu, 30 Jan 2025 22:31:35 -0800 Subject: [PATCH 06/27] format --- ...Microsoft.ML.OnnxRuntime.Tests.MAUI.csproj | 249 +++++++++--------- 1 file changed, 125 insertions(+), 124 deletions(-) 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 638e4a95fcaf9..d23c8f1f52b8a 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,132 +1,133 @@ - - - $(ProjectDir)..\..\.. - + + + $(ProjectDir)..\..\.. - + - - - net8.0-android;net8.0-ios;net8.0-maccatalyst - $(TargetFrameworks);net8.0-windows10.0.19041.0 + 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'))" /> - - - - - - - - - - false - en - - - - apk - - - + + + Exe + Microsoft.ML.OnnxRuntime.Tests.MAUI + true + true + enable + enable + true < !--some of the helper packages don't have strong named assemblies. --> < NoWarn > 8002 < / NoWarn > + + + $(DefineConstants); +INCLUDE_FAILING_TESTS + $(DefineConstants); +MODE_NON_INTERACTIVE_VISUAL + $(DefineConstants); +MODE_XHARNESS + + + Microsoft.ML.OnnxRuntime.Tests.MAUI + + + ORT.CSharp.Tests.MAUI + + < ApplicationDisplayVersion > 1.0 < / ApplicationDisplayVersion > + < ApplicationVersion > 1 < / ApplicationVersion > + + < SupportedOSPlatformVersion Condition = "'$(IsIOSTarget)' == 'true'" > 15.0 < / SupportedOSPlatformVersion > + < SupportedOSPlatformVersion Condition = "'$(IsMacCatalystTarget)' == 'true'" > 13.1 < / SupportedOSPlatformVersion > + < SupportedOSPlatformVersion Condition = "'$(IsAndroidTarget)' == 'true'" > 30.0 < / SupportedOSPlatformVersion > + < SupportedOSPlatformVersion Condition = "'$(IsWindowsTarget)' == 'true'" > 10.0.17763.0 < / SupportedOSPlatformVersion > + < TargetPlatformMinVersion Condition = "'$(IsWindowsTarget)' == 'true'" > 10.0.17763.0 < / TargetPlatformMinVersion > + + true + ..\..\OnnxRuntime.snk + + + + + + + + + + + + + + + + + + + + + + + + InferenceTest.cs + + + OrtIoBindingAllocationTest.cs + + + TensorTests.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_VisualStudioTestRunnerFiles Include = "@(PackagingOutputs)" Condition = "$([System.String]::Copy('%(PackagingOutputs.FullPath)').Contains('xunit.runner.visualstudio'))" /> + + + + + + + + + + false + en + + + + apk + + + From 773cbb6eb0001223313ff58338c40c4966d82627 Mon Sep 17 00:00:00 2001 From: carzh Date: Thu, 30 Jan 2025 22:32:51 -0800 Subject: [PATCH 07/27] Revert "format" This reverts commit 70e3a2362a8e1269298570291400f24492a612b5. --- ...Microsoft.ML.OnnxRuntime.Tests.MAUI.csproj | 249 +++++++++--------- 1 file changed, 124 insertions(+), 125 deletions(-) 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 d23c8f1f52b8a..638e4a95fcaf9 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,133 +1,132 @@ - - - $(ProjectDir)..\..\.. + + + $(ProjectDir)..\..\.. + - + - net8.0 - - android; -net8.0 - ios; -net8.0 - maccatalyst - $(TargetFrameworks);net8.0-windows10.0.19041.0 + + + 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 < !--some of the helper packages don't have strong named assemblies. --> < NoWarn > 8002 < / NoWarn > - - - $(DefineConstants); -INCLUDE_FAILING_TESTS - $(DefineConstants); -MODE_NON_INTERACTIVE_VISUAL - $(DefineConstants); -MODE_XHARNESS - - - Microsoft.ML.OnnxRuntime.Tests.MAUI - - - ORT.CSharp.Tests.MAUI - - < ApplicationDisplayVersion > 1.0 < / ApplicationDisplayVersion > - < ApplicationVersion > 1 < / ApplicationVersion > - - < SupportedOSPlatformVersion Condition = "'$(IsIOSTarget)' == 'true'" > 15.0 < / SupportedOSPlatformVersion > - < SupportedOSPlatformVersion Condition = "'$(IsMacCatalystTarget)' == 'true'" > 13.1 < / SupportedOSPlatformVersion > - < SupportedOSPlatformVersion Condition = "'$(IsAndroidTarget)' == 'true'" > 30.0 < / SupportedOSPlatformVersion > - < SupportedOSPlatformVersion Condition = "'$(IsWindowsTarget)' == 'true'" > 10.0.17763.0 < / SupportedOSPlatformVersion > - < TargetPlatformMinVersion Condition = "'$(IsWindowsTarget)' == 'true'" > 10.0.17763.0 < / TargetPlatformMinVersion > - - true - ..\..\OnnxRuntime.snk - - - - - - - - - - - - - - - - - - - - - - - - InferenceTest.cs - - - OrtIoBindingAllocationTest.cs - - - TensorTests.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_VisualStudioTestRunnerFiles Include = "@(PackagingOutputs)" Condition = "$([System.String]::Copy('%(PackagingOutputs.FullPath)').Contains('xunit.runner.visualstudio'))" /> - - - - - - - - - - false - en - - - - apk - - - + + + 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'))" /> + + + + + + + + + + false + en + + + + apk + + + From 657c60d7944249c7ee5b45a68462fe121a9293fc Mon Sep 17 00:00:00 2001 From: carzh Date: Thu, 30 Jan 2025 22:34:03 -0800 Subject: [PATCH 08/27] format again.. --- .../Microsoft.ML.OnnxRuntime.Tests.MAUI.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 638e4a95fcaf9..351385b442670 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 @@ -126,7 +126,7 @@ - apk + apk From 7a51dd5de9f7450089572a60a9e7e43c7e117c1e Mon Sep 17 00:00:00 2001 From: carzh Date: Thu, 30 Jan 2025 22:38:38 -0800 Subject: [PATCH 09/27] fixed format again --- ...Microsoft.ML.OnnxRuntime.Tests.MAUI.csproj | 258 +++++++++--------- 1 file changed, 129 insertions(+), 129 deletions(-) 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 351385b442670..e25b4a81a7018 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,132 +1,132 @@  - - $(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'))" /> - - - - - - - - - - false - en - - - - apk - + + $(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'))" /> + + + + + + + + + + false + en + + + + apk + From 573e284838517441773e0042da0947bd4af2d31b Mon Sep 17 00:00:00 2001 From: carzh Date: Mon, 3 Feb 2025 10:58:12 -0800 Subject: [PATCH 10/27] removed modifications from sln and commented out the ios and maccatylst targets --- csharp/OnnxRuntime.CSharp.sln | 7 +++++++ .../Microsoft.ML.OnnxRuntime.Tests.MAUI.csproj | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/csharp/OnnxRuntime.CSharp.sln b/csharp/OnnxRuntime.CSharp.sln index ed87fcb9e17d6..4556be2aa2b02 100644 --- a/csharp/OnnxRuntime.CSharp.sln +++ b/csharp/OnnxRuntime.CSharp.sln @@ -89,6 +89,7 @@ Global {2E295930-42B1-422D-925D-F07947AD8EFF}.Release|x86.ActiveCfg = Release|Any CPU {2E295930-42B1-422D-925D-F07947AD8EFF}.Release|x86.Build.0 = Release|Any CPU {2E295930-42B1-422D-925D-F07947AD8EFF}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {2E295930-42B1-422D-925D-F07947AD8EFF}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU {2E295930-42B1-422D-925D-F07947AD8EFF}.RelWithDebInfo|iPhone.ActiveCfg = Release|Any CPU {2E295930-42B1-422D-925D-F07947AD8EFF}.RelWithDebInfo|iPhone.Build.0 = Release|Any CPU {2E295930-42B1-422D-925D-F07947AD8EFF}.RelWithDebInfo|iPhoneSimulator.ActiveCfg = Release|Any CPU @@ -120,6 +121,7 @@ Global {037242E4-7C79-401F-A19C-6824B1BB356F}.Release|x86.Build.0 = Release|Any CPU {037242E4-7C79-401F-A19C-6824B1BB356F}.Release|x86.Deploy.0 = Release|Any CPU {037242E4-7C79-401F-A19C-6824B1BB356F}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {037242E4-7C79-401F-A19C-6824B1BB356F}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU {037242E4-7C79-401F-A19C-6824B1BB356F}.RelWithDebInfo|Any CPU.Deploy.0 = Release|Any CPU {037242E4-7C79-401F-A19C-6824B1BB356F}.RelWithDebInfo|iPhone.ActiveCfg = Release|Any CPU {037242E4-7C79-401F-A19C-6824B1BB356F}.RelWithDebInfo|iPhone.Build.0 = Release|Any CPU @@ -147,6 +149,7 @@ Global {1AA14958-9246-4163-9403-F650E65ADCBC}.Release|x86.ActiveCfg = Release|x86 {1AA14958-9246-4163-9403-F650E65ADCBC}.Release|x86.Build.0 = Release|x86 {1AA14958-9246-4163-9403-F650E65ADCBC}.RelWithDebInfo|Any CPU.ActiveCfg = RelWithDebInfo|Any CPU + {1AA14958-9246-4163-9403-F650E65ADCBC}.RelWithDebInfo|Any CPU.Build.0 = RelWithDebInfo|Any CPU {1AA14958-9246-4163-9403-F650E65ADCBC}.RelWithDebInfo|iPhone.ActiveCfg = RelWithDebInfo|Any CPU {1AA14958-9246-4163-9403-F650E65ADCBC}.RelWithDebInfo|iPhone.Build.0 = RelWithDebInfo|Any CPU {1AA14958-9246-4163-9403-F650E65ADCBC}.RelWithDebInfo|iPhoneSimulator.ActiveCfg = RelWithDebInfo|Any CPU @@ -194,6 +197,7 @@ Global {04FA49F0-AA23-4EE5-B455-6E12FFAD29E6}.Release|x86.ActiveCfg = Release|x86 {04FA49F0-AA23-4EE5-B455-6E12FFAD29E6}.Release|x86.Build.0 = Release|x86 {04FA49F0-AA23-4EE5-B455-6E12FFAD29E6}.RelWithDebInfo|Any CPU.ActiveCfg = RelWithDebInfo|Any CPU + {04FA49F0-AA23-4EE5-B455-6E12FFAD29E6}.RelWithDebInfo|Any CPU.Build.0 = RelWithDebInfo|Any CPU {04FA49F0-AA23-4EE5-B455-6E12FFAD29E6}.RelWithDebInfo|iPhone.ActiveCfg = RelWithDebInfo|Any CPU {04FA49F0-AA23-4EE5-B455-6E12FFAD29E6}.RelWithDebInfo|iPhone.Build.0 = RelWithDebInfo|Any CPU {04FA49F0-AA23-4EE5-B455-6E12FFAD29E6}.RelWithDebInfo|iPhoneSimulator.ActiveCfg = RelWithDebInfo|Any CPU @@ -217,6 +221,7 @@ Global {50173D13-DF29-42E7-A30B-8B12D36C77B1}.Release|x86.ActiveCfg = Release|x86 {50173D13-DF29-42E7-A30B-8B12D36C77B1}.Release|x86.Build.0 = Release|x86 {50173D13-DF29-42E7-A30B-8B12D36C77B1}.RelWithDebInfo|Any CPU.ActiveCfg = RelWithDebInfo|Any CPU + {50173D13-DF29-42E7-A30B-8B12D36C77B1}.RelWithDebInfo|Any CPU.Build.0 = RelWithDebInfo|Any CPU {50173D13-DF29-42E7-A30B-8B12D36C77B1}.RelWithDebInfo|iPhone.ActiveCfg = RelWithDebInfo|Any CPU {50173D13-DF29-42E7-A30B-8B12D36C77B1}.RelWithDebInfo|iPhone.Build.0 = RelWithDebInfo|Any CPU {50173D13-DF29-42E7-A30B-8B12D36C77B1}.RelWithDebInfo|iPhoneSimulator.ActiveCfg = RelWithDebInfo|Any CPU @@ -240,6 +245,7 @@ Global {30431891-3929-4394-8049-75055B92315F}.Release|x86.ActiveCfg = Release|Any CPU {30431891-3929-4394-8049-75055B92315F}.Release|x86.Build.0 = Release|Any CPU {30431891-3929-4394-8049-75055B92315F}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {30431891-3929-4394-8049-75055B92315F}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU {30431891-3929-4394-8049-75055B92315F}.RelWithDebInfo|iPhone.ActiveCfg = Release|Any CPU {30431891-3929-4394-8049-75055B92315F}.RelWithDebInfo|iPhone.Build.0 = Release|Any CPU {30431891-3929-4394-8049-75055B92315F}.RelWithDebInfo|iPhoneSimulator.ActiveCfg = Release|Any CPU @@ -295,6 +301,7 @@ Global {85E4F8C9-366A-4769-8DBC-ABCDE37FD460}.Release|x86.Build.0 = Release|Any CPU {85E4F8C9-366A-4769-8DBC-ABCDE37FD460}.Release|x86.Deploy.0 = Release|Any CPU {85E4F8C9-366A-4769-8DBC-ABCDE37FD460}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU + {85E4F8C9-366A-4769-8DBC-ABCDE37FD460}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU {85E4F8C9-366A-4769-8DBC-ABCDE37FD460}.RelWithDebInfo|Any CPU.Deploy.0 = Release|Any CPU {85E4F8C9-366A-4769-8DBC-ABCDE37FD460}.RelWithDebInfo|iPhone.ActiveCfg = Release|Any CPU {85E4F8C9-366A-4769-8DBC-ABCDE37FD460}.RelWithDebInfo|iPhone.Build.0 = Release|Any CPU 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 e25b4a81a7018..346f88e856f08 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 @@ -7,7 +7,11 @@ - net8.0-android;net8.0-ios;net8.0-maccatalyst + + + + net8.0-android $(TargetFrameworks);net8.0-windows10.0.19041.0 - + net8.0-android From 2c17720f730bd5a93a3c59423e0f67588c0c7b94 Mon Sep 17 00:00:00 2001 From: carzh Date: Tue, 4 Feb 2025 13:50:28 -0800 Subject: [PATCH 12/27] added test_android yml + added it to nuget pipeline --- .../nuget/templates/test_android.yml | 63 +++++++++++++++++++ .../azure-pipelines/templates/c-api-cpu.yml | 7 +++ 2 files changed, 70 insertions(+) create mode 100644 tools/ci_build/github/azure-pipelines/nuget/templates/test_android.yml diff --git a/tools/ci_build/github/azure-pipelines/nuget/templates/test_android.yml b/tools/ci_build/github/azure-pipelines/nuget/templates/test_android.yml new file mode 100644 index 0000000000000..33714473b5b16 --- /dev/null +++ b/tools/ci_build/github/azure-pipelines/nuget/templates/test_android.yml @@ -0,0 +1,63 @@ +parameters: + AgentPool : 'Win-CPU' + ArtifactSuffix: '' + SpecificArtifact: false + BuildId: '' + +stages: +- stage: NuGet_Test_Android + jobs: + - job: NuGet_Test_Android + workspace: + clean: all + pool: "${{ parameters.AgentPool }}" + + variables: + - name: OnnxRuntimeBuildDirectory + value: '$(Build.BinariesDirectory)' + + steps: + - task: NuGetToolInstaller@0 + displayName: Use Nuget 6.10.x + inputs: + versionSpec: 6.10.x + + - template: ../../templates/flex-downloadPipelineArtifact.yml + parameters: + StepName: 'Download Pipeline Artifact' + ArtifactName: drop-signed-nuget-${{ parameters.ArtifactSuffix }} + TargetPath: '$(Build.BinariesDirectory)\nuget-artifact' + SpecificArtifact: ${{ parameters.SpecificArtifact }} + BuildId: ${{ parameters.BuildId }} + + - template: get-nuget-package-version-as-variable.yml + parameters: + packageFolder: '$(Build.BinariesDirectory)\nuget-artifact' + + - task: PowerShell@2 + displayName: Install MAUI workloads + inputs: + targetType: 'inline' + script: | + dotnet workload install maui maui-android android + workingDirectory: '$(Build.SourcesDirectory)\csharp' + + - task: PowerShell@2 + displayName: Publish Android MAUI APK + inputs: + targetType: 'inline' + script: | + dotnet nuget add source $(Build.BinariesDirectory)\nuget-artifact --name local-nuget + dotnet publish -c Release --property:UsePrebuiltNativePackage=true --property:CurrentOnnxRuntimeVersion=$(NuGetPackageVersionNumber) -f net8.0-android + workingDirectory: '$(Build.SourcesDirectory)\csharp\test\Microsoft.ML.OnnxRuntime.Tests.MAUI' + + - task: PowerShell@2 + displayName: Run BrowserStack test + inputs: + targetType: 'inline' + script: | + dotnet test + workingDirectory: '$(Build.SourcesDirectory)\csharp\test\Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android' + env: + BROWSERSTACK_USERNAME: $(browserstack_username) + BROWSERSTACK_ACCESS_KEY: $(browserstack_access_key) diff --git a/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml b/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml index 1ab4fd2a8e9e7..0d7d46387666c 100644 --- a/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml +++ b/tools/ci_build/github/azure-pipelines/templates/c-api-cpu.yml @@ -810,6 +810,13 @@ stages: SpecificArtifact: ${{ parameters.SpecificArtifact }} BuildId: ${{ parameters.BuildId }} +- template: ../nuget/templates/test_android.yml + parameters: + AgentPool : 'onnxruntime-Win-CPU-2022' + ArtifactSuffix: 'CPU' + SpecificArtifact: ${{ parameters.SpecificArtifact }} + BuildId: ${{ parameters.BuildId }} + - template: ../nuget/templates/test_linux.yml parameters: AgentPool : onnxruntime-Ubuntu2204-AMD-CPU From fba54160058afcc87b22d2c6fba67a957c21a6aa Mon Sep 17 00:00:00 2001 From: carzh Date: Tue, 4 Feb 2025 13:53:53 -0800 Subject: [PATCH 13/27] fixed indent --- .../nuget/templates/test_android.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/ci_build/github/azure-pipelines/nuget/templates/test_android.yml b/tools/ci_build/github/azure-pipelines/nuget/templates/test_android.yml index 33714473b5b16..c988a97b6a56c 100644 --- a/tools/ci_build/github/azure-pipelines/nuget/templates/test_android.yml +++ b/tools/ci_build/github/azure-pipelines/nuget/templates/test_android.yml @@ -22,13 +22,13 @@ stages: inputs: versionSpec: 6.10.x - - template: ../../templates/flex-downloadPipelineArtifact.yml - parameters: - StepName: 'Download Pipeline Artifact' - ArtifactName: drop-signed-nuget-${{ parameters.ArtifactSuffix }} - TargetPath: '$(Build.BinariesDirectory)\nuget-artifact' - SpecificArtifact: ${{ parameters.SpecificArtifact }} - BuildId: ${{ parameters.BuildId }} + - template: ../../templates/flex-downloadPipelineArtifact.yml + parameters: + StepName: 'Download Pipeline Artifact' + ArtifactName: drop-signed-nuget-${{ parameters.ArtifactSuffix }} + TargetPath: '$(Build.BinariesDirectory)\nuget-artifact' + SpecificArtifact: ${{ parameters.SpecificArtifact }} + BuildId: ${{ parameters.BuildId }} - template: get-nuget-package-version-as-variable.yml parameters: From 1815b9628036198e7788c8d7a4f2de6f6f59f81f Mon Sep 17 00:00:00 2001 From: carzh Date: Thu, 6 Feb 2025 17:49:08 -0800 Subject: [PATCH 14/27] fixed curly bracket / ascii processing issue --- .../BrowserStackTest.cs | 4 ++-- .../RunAllTest.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/BrowserStackTest.cs b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/BrowserStackTest.cs index 84377d65d1213..6ab341d75683f 100644 --- a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/BrowserStackTest.cs +++ b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/BrowserStackTest.cs @@ -45,8 +45,8 @@ public void Dispose() { String failureMessage = TestContext.CurrentContext.Result.Message; String jsonToSendFailure = - String.Format("browserstack_executor: {\"action\": \"setSessionStatus\", \"arguments\": " + - "{\"status\":\"failed\", \"reason\": {0}}}", + String.Format("browserstack_executor: {{\"action\": \"setSessionStatus\", \"arguments\": " + + "{{\"status\":\"failed\", \"reason\": {0}}}}}", JsonConvert.ToString(failureMessage)); ((IJavaScriptExecutor)driver).ExecuteScript(jsonToSendFailure); diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/RunAllTest.cs b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/RunAllTest.cs index 5db3dc9957d1c..b62c2f052455e 100644 --- a/csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/RunAllTest.cs +++ b/csharp/test/Microsoft.ML.OnnxRuntime.Tests.BrowserStack.Android/RunAllTest.cs @@ -89,7 +89,7 @@ public async Task ClickRunAllTest() await Task.Delay(500); } - var (numPassed, numFailed) = GetPassFailCount(); + (int numPassed, int numFailed) = GetPassFailCount(); if (numFailed == 0) { From e6cd1e80708ec494a9c2b03cd3f1573478a1da6a Mon Sep 17 00:00:00 2001 From: carzh Date: Fri, 7 Feb 2025 13:05:58 -0800 Subject: [PATCH 15/27] disable aot compilation for inference sample to see if that resolves pipeline error --- .../Microsoft.ML.OnnxRuntime.InferenceSample.Maui.csproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/csharp/sample/InferenceSample/Microsoft.ML.OnnxRuntime.InferenceSample.Maui/Microsoft.ML.OnnxRuntime.InferenceSample.Maui.csproj b/csharp/sample/InferenceSample/Microsoft.ML.OnnxRuntime.InferenceSample.Maui/Microsoft.ML.OnnxRuntime.InferenceSample.Maui.csproj index 73a535999672c..e3a640fc6baf3 100644 --- a/csharp/sample/InferenceSample/Microsoft.ML.OnnxRuntime.InferenceSample.Maui/Microsoft.ML.OnnxRuntime.InferenceSample.Maui.csproj +++ b/csharp/sample/InferenceSample/Microsoft.ML.OnnxRuntime.InferenceSample.Maui/Microsoft.ML.OnnxRuntime.InferenceSample.Maui.csproj @@ -28,6 +28,10 @@ en + + False + +