diff --git a/csharp/OnnxRuntime.CSharp.proj b/csharp/OnnxRuntime.CSharp.proj index 0288d752d8..69bfd9896f 100644 --- a/csharp/OnnxRuntime.CSharp.proj +++ b/csharp/OnnxRuntime.CSharp.proj @@ -17,9 +17,13 @@ CMake creates a target to this project x64 false - false + true + true None + + true + .. ..\tools\nuget\generate_nuspec_for_native_nuget.py @@ -30,13 +34,15 @@ CMake creates a target to this project ..\build\Linux $(OnnxRuntimeBuildDirectory)\packages $(OnnxRuntimeBuildDirectory)\$(Configuration) + python3 - + ..\build\Windows $(OnnxRuntimeBuildDirectory)\packages $(OnnxRuntimeBuildDirectory)\$(Configuration)\$(Configuration) + python @@ -86,28 +92,48 @@ CMake creates a target to this project - + + + Properties="NoBuild=true;Platform=AnyCPU;PackageVersion=$(PackageVersion);OrtPackageId=$(OrtPackageId);IncludeMobileTargets=$(IncludeMobileTargets)"/> - - + + + - - + + + - + + + + - diff --git a/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj b/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj index 29ccf55f08..0c74a23204 100644 --- a/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj +++ b/csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj @@ -4,66 +4,53 @@ Microsoft.ML.OnnxRuntime - - PreNet6 - netstandard2.0;netcoreapp3.1;net6.0 + true + netstandard2.0 + - + + + false + + + - xamarinios10;monoandroid11.0 + '$(IncludeMobileTargets)' == 'true' AND + Exists('$(MSBuildExtensionsPath)\Xamarin\Android') AND + Exists('$(MSBuildExtensionsPath)\Xamarin\iOS')"> + xamarinios10;monoandroid11.0 - - monoandroid11.0 + + monoandroid11.0 - + - net6.0;net6.0-android;net6.0-ios;net6.0-macos + '$(OrtPackageId)' == 'Microsoft.ML.OnnxRuntime.Azure') AND + '$(IncludeMobileTargets)' == 'true'"> + $(MobileTargets);net6.0-android;net6.0-ios - - net6.0;net6.0-android + + $(MobileTargets);net6.0-android - - $(BaseTargets);$(XamarinTargets);$(XamarinTargetsForTraining) + + $(BaseTargets);$(MobileTargets) - - $(Net6Targets);$(Net6TargetsForTrainingPackage) - - - - - $(BaseTargets);$(XamarinTargets);$(XamarinTargetsForTraining);$(Net6Targets);$(Net6TargetsForTrainingPackage) - - - AnyCPU;x86 default @@ -204,8 +191,9 @@ $(DefineConstants);$(OrtConstants) - + @@ -214,7 +202,6 @@ - --> + + + netstandard2.0 + $(OnnxRuntimeBuildDirectory)/NativeNuget.nuspec + + diff --git a/tools/ci_build/build.py b/tools/ci_build/build.py index a992da8ff9..25d69ef3a1 100644 --- a/tools/ci_build/build.py +++ b/tools/ci_build/build.py @@ -796,6 +796,7 @@ def run_subprocess( my_env.update(env) + log.info(" ".join(args)) return run(*args, cwd=cwd, capture_stdout=capture_stdout, shell=shell, env=my_env) @@ -2024,13 +2025,6 @@ def build_python_wheel( run_subprocess(args, cwd=cwd) -def derive_linux_build_property(): - if is_windows(): - return '/p:IsLinuxBuild="false"' - else: - return '/p:IsLinuxBuild="true"' - - def build_nuget_package( cmake_path, source_dir, @@ -2043,7 +2037,6 @@ def build_nuget_package( use_dnnl, use_tvm, use_winml, - use_snpe, use_qnn, enable_training_apis, msbuild_extra_options, @@ -2054,83 +2047,93 @@ def build_nuget_package( ) csharp_build_dir = os.path.join(source_dir, "csharp") - is_linux_build = derive_linux_build_property() # in most cases we don't want/need to include the Xamarin mobile targets, as doing so means the Xamarin # mobile workloads must be installed on the machine. # they are only included in the Microsoft.ML.OnnxRuntime nuget package sln = "OnnxRuntime.DesktopOnly.CSharp.sln" + have_exclude_mobile_targets_option = "IncludeMobileTargets=false" in msbuild_extra_options # derive package name and execution provider based on the build args target_name = "/t:CreatePackage" - execution_provider = '/p:ExecutionProvider="None"' - package_name = '/p:OrtPackageId="Microsoft.ML.OnnxRuntime"' - enable_training_tests = '/p:TrainingEnabledNativeBuild="false"' + execution_provider = "/p:ExecutionProvider=None" + package_name = "/p:OrtPackageId=Microsoft.ML.OnnxRuntime" + enable_training_tests = "/p:TrainingEnabledNativeBuild=false" + if enable_training_apis: - enable_training_tests = '/p:TrainingEnabledNativeBuild="true"' + enable_training_tests = "/p:TrainingEnabledNativeBuild=true" if use_cuda: - package_name = '/p:OrtPackageId="Microsoft.ML.OnnxRuntime.Training.Gpu"' + package_name = "/p:OrtPackageId=Microsoft.ML.OnnxRuntime.Training.Gpu" else: - package_name = '/p:OrtPackageId="Microsoft.ML.OnnxRuntime.Training"' + package_name = "/p:OrtPackageId=Microsoft.ML.OnnxRuntime.Training" elif use_winml: - package_name = '/p:OrtPackageId="Microsoft.AI.MachineLearning"' + package_name = "/p:OrtPackageId=Microsoft.AI.MachineLearning" target_name = "/t:CreateWindowsAIPackage" elif use_openvino: - execution_provider = '/p:ExecutionProvider="openvino"' - package_name = '/p:OrtPackageId="Microsoft.ML.OnnxRuntime.OpenVino"' + execution_provider = "/p:ExecutionProvider=openvino" + package_name = "/p:OrtPackageId=Microsoft.ML.OnnxRuntime.OpenVino" elif use_tensorrt: - execution_provider = '/p:ExecutionProvider="tensorrt"' - package_name = '/p:OrtPackageId="Microsoft.ML.OnnxRuntime.TensorRT"' + execution_provider = "/p:ExecutionProvider=tensorrt" + package_name = "/p:OrtPackageId=Microsoft.ML.OnnxRuntime.TensorRT" elif use_dnnl: - execution_provider = '/p:ExecutionProvider="dnnl"' - package_name = '/p:OrtPackageId="Microsoft.ML.OnnxRuntime.DNNL"' + execution_provider = "/p:ExecutionProvider=dnnl" + package_name = "/p:OrtPackageId=Microsoft.ML.OnnxRuntime.DNNL" elif use_cuda: - package_name = '/p:OrtPackageId="Microsoft.ML.OnnxRuntime.Gpu"' + package_name = "/p:OrtPackageId=Microsoft.ML.OnnxRuntime.Gpu" elif use_rocm: - package_name = '/p:OrtPackageId="Microsoft.ML.OnnxRuntime.ROCm"' + package_name = "/p:OrtPackageId=Microsoft.ML.OnnxRuntime.ROCm" elif use_tvm: - execution_provider = '/p:ExecutionProvider="tvm"' - package_name = '/p:OrtPackageId="Microsoft.ML.OnnxRuntime.Tvm"' - elif use_snpe: - execution_provider = '/p:ExecutionProvider="snpe"' - package_name = '/p:OrtPackageId="Microsoft.ML.OnnxRuntime.Snpe"' + execution_provider = "/p:ExecutionProvider=tvm" + package_name = "/p:OrtPackageId=Microsoft.ML.OnnxRuntime.Tvm" elif use_qnn: - execution_provider = '/p:ExecutionProvider="qnn"' - package_name = '/p:OrtPackageId="Microsoft.ML.OnnxRuntime.QNN"' + execution_provider = "/p:ExecutionProvider=qnn" + package_name = "/p:OrtPackageId=Microsoft.ML.OnnxRuntime.QNN" elif any(map(lambda x: "OrtPackageId=" in x, msbuild_extra_options)): pass else: - # use the solution file that includes Xamarin mobile targets - sln = "OnnxRuntime.CSharp.sln" + # we currently only allow building with mobile targets on Windows. + # it should be possible to allow building with android targets on Linux but that requires updating the + # csproj to separate the inclusion of ios and android targets. + if is_windows() and have_exclude_mobile_targets_option is False: + # use the sln that include the mobile targets + sln = "OnnxRuntime.CSharp.sln" + + # explicitly exclude mobile targets in this case + if sln != "OnnxRuntime.CSharp.sln" and have_exclude_mobile_targets_option is False: + msbuild_extra_options.append("IncludeMobileTargets=false") + + # expand extra_options to add prefix + extra_options = ["/p:" + option for option in msbuild_extra_options] + + # we have to use msbuild directly if including Xamarin targets as dotnet only supports MAUI (.net6) + use_dotnet = sln != "OnnxRuntime.CSharp.sln" + + if use_dotnet: + cmd_args = ["dotnet", "restore", sln, "--configfile", "NuGet.CSharp.config", *extra_options] + else: + cmd_args = ["msbuild", sln, "/t:restore", "/p:RestoreConfigFile=NuGet.CSharp.config", *extra_options] # set build directory based on build_dir arg native_dir = os.path.normpath(os.path.join(source_dir, build_dir)) - ort_build_dir = '/p:OnnxRuntimeBuildDirectory="' + native_dir + '"' + ort_build_dir = "/p:OnnxRuntimeBuildDirectory=" + native_dir - # dotnet restore - cmd_args = ["dotnet", "restore", sln, "--configfile", "NuGet.CSharp.config"] run_subprocess(cmd_args, cwd=csharp_build_dir) # build csharp bindings and create nuget package for each config for config in configs: - if is_linux(): - native_build_dir = os.path.join(native_dir, config) - cmd_args = [cmake_path, "-DCMAKE_INSTALL_PREFIX=./nuget-staging/usr/local", "-Pcmake_install.cmake"] - run_subprocess(cmd_args, cwd=native_build_dir) - - configuration = '/p:Configuration="' + config + '"' - + configuration = "/p:Configuration=" + config if not use_winml: - cmd_args = [ - "dotnet", + cmd_args = ["dotnet"] if use_dotnet else [] + cmd_args += [ "msbuild", sln, configuration, package_name, - is_linux_build, ort_build_dir, enable_training_tests, + *extra_options, ] + run_subprocess(cmd_args, cwd=csharp_build_dir) else: winml_interop_dir = os.path.join(source_dir, "csharp", "src", "Microsoft.AI.MachineLearning.Interop") @@ -2141,7 +2144,7 @@ def build_nuget_package( "msbuild", winml_interop_project, configuration, - '/p:Platform="Any CPU"', + "/p:Platform=Any CPU", ort_build_dir, "-restore", ] @@ -2155,26 +2158,28 @@ def build_nuget_package( # this path is setup by cmake/nuget_helpers.cmake for MSVC on Windows nuget_exe = os.path.normpath(os.path.join(native_dir, config, "nuget_exe", "src", "nuget.exe")) else: - # user needs to make sure nuget is installed and can be found - nuget_exe = "nuget" + # `dotnet pack` is used on Linux + nuget_exe = "NugetExe_not_set" nuget_exe_arg = '/p:NugetExe="' + nuget_exe + '"' - cmd_args = [ - "dotnet", + cmd_args = ["dotnet"] if use_dotnet else [] + cmd_args += [ "msbuild", "OnnxRuntime.CSharp.proj", target_name, package_name, configuration, execution_provider, - is_linux_build, ort_build_dir, nuget_exe_arg, + *extra_options, ] - cmd_args.extend(msbuild_extra_options) + run_subprocess(cmd_args, cwd=csharp_build_dir) + log.info(f"nuget package was created in the {config} build output directory.") + def run_csharp_tests(source_dir, build_dir, use_cuda, use_openvino, use_tensorrt, use_dnnl, enable_training_apis): # Currently only running tests on windows. @@ -2637,6 +2642,7 @@ def main(): enable_training_apis=args.enable_training_apis, enable_rocm_profiling=args.enable_rocm_profiling, ) + if args.build_nuget: build_nuget_package( cmake_path, @@ -2650,7 +2656,6 @@ def main(): args.use_dnnl, args.use_tvm, args.use_winml, - args.use_snpe, args.use_qnn, args.enable_training_apis, normalize_arg_list(args.msbuild_extra_options), diff --git a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml index 14a9bbedf0..ac07d8c525 100644 --- a/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml +++ b/tools/ci_build/github/azure-pipelines/c-api-noopenmp-packaging-pipelines.yml @@ -716,44 +716,29 @@ stages: versionSpec: 6.2.1 - task: PowerShell@2 - displayName: Install .NET 6 workloads + displayName: Install mobile workloads inputs: targetType: 'inline' script: | - dotnet workload install android ios macos - workingDirectory: '$(Build.SourcesDirectory)\csharp' - - - task: PowerShell@2 - displayName: Build .NET 6 targets using dotnet - inputs: - targetType: 'inline' - # we don't specify 'Any CPU' as the platform here because if we do it gets added to the output path - # e.g. csharp\src\Microsoft.ML.OnnxRuntime\bin\Any CPU\RelWithDebInfo\net6.0-ios\ - # which is inconsistent with the msbuild output path for the pre-.net6 targets - # e.g. csharp\src\Microsoft.ML.OnnxRuntime\bin\RelWithDebInfo\monoandroid11.0 - # and makes it harder to do the packing - # - # 'Any CPU' is the default (first 'mixed' platform specified in the csproj) so this should be fine. - script: | - dotnet build .\src\Microsoft.ML.OnnxRuntime\Microsoft.ML.OnnxRuntime.csproj -p:SelectedTargets=Net6 -p:Configuration=RelWithDebInfo -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId="Microsoft.ML.OnnxRuntime.Gpu" -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix) + dotnet workload install android ios workingDirectory: '$(Build.SourcesDirectory)\csharp' - task: MSBuild@1 - displayName: 'Restore NuGet Packages and create project.assets.json for pre-.net6 targets' + displayName: 'Restore NuGet Packages and create project.assets.json' inputs: solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.sln' platform: 'Any CPU' configuration: RelWithDebInfo - msbuildArguments: '-t:restore -p:SelectedTargets=PreNet6 -p:OrtPackageId="Microsoft.ML.OnnxRuntime.Gpu"' + msbuildArguments: '-t:restore -p:OrtPackageId="Microsoft.ML.OnnxRuntime.Gpu"' workingDirectory: '$(Build.SourcesDirectory)\csharp' - task: MSBuild@1 - displayName: 'Build C# for pre-.net6 targets' + displayName: 'Build C# bindings' inputs: solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.sln' configuration: RelWithDebInfo platform: 'Any CPU' - msbuildArguments: '-p:SelectedTargets=PreNet6 -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId="Microsoft.ML.OnnxRuntime.Gpu" -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix)' + msbuildArguments: '-p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId="Microsoft.ML.OnnxRuntime.Gpu" -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix)' workingDirectory: '$(Build.SourcesDirectory)\csharp' - template: templates/win-esrp-dll.yml @@ -762,15 +747,6 @@ stages: DisplayName: 'ESRP - Sign C# dlls' DoEsrp: ${{ parameters.DoEsrp }} - - task: MSBuild@1 - displayName: Update projects.assets.json with combined list of all target frameworks - inputs: - solution: '$(Build.SourcesDirectory)\csharp\src\Microsoft.ML.OnnxRuntime\Microsoft.ML.OnnxRuntime.csproj' - platform: 'Any CPU' - configuration: RelWithDebInfo - msbuildArguments: '-t:restore -p:SelectedTargets=All -p:OrtPackageId=Microsoft.ML.OnnxRuntime.Gpu' - workingDirectory: '$(Build.SourcesDirectory)\csharp' - - task: MSBuild@1 displayName: 'Build Nuget Packages' inputs: diff --git a/tools/ci_build/github/azure-pipelines/nuget/templates/dml-vs-2022.yml b/tools/ci_build/github/azure-pipelines/nuget/templates/dml-vs-2022.yml index 81e8d67b79..2d92108efb 100644 --- a/tools/ci_build/github/azure-pipelines/nuget/templates/dml-vs-2022.yml +++ b/tools/ci_build/github/azure-pipelines/nuget/templates/dml-vs-2022.yml @@ -137,7 +137,7 @@ stages: - task: MSBuild@1 displayName: 'Restore NuGet Packages' inputs: - solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.sln' + solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.DesktopOnly.CSharp.sln' platform: 'Any CPU' configuration: '$(BuildConfig)' msbuildArguments: '-t:restore -p:OrtPackageId=${{ parameters.OrtPackageId }}' @@ -146,7 +146,7 @@ stages: - task: MSBuild@1 displayName: 'Build C#' inputs: - solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.sln' + solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.DesktopOnly.CSharp.sln' configuration: '$(BuildConfig)' platform: 'Any CPU' msbuildArguments: '-p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=${{ parameters.OrtPackageId }} -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }}' 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 af245c9970..4ce39ecc35 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 @@ -398,44 +398,29 @@ stages: versionSpec: 6.2.1 - task: PowerShell@2 - displayName: Install .NET 6 workloads + displayName: Install mobile workloads inputs: targetType: 'inline' script: | - dotnet workload install android ios macos - workingDirectory: '$(Build.SourcesDirectory)\csharp' - - - task: PowerShell@2 - displayName: Build Microsoft.ML.OnnxRuntime .NET 6 targets using dotnet - inputs: - targetType: 'inline' - # we don't specify 'Any CPU' as the platform here because if we do it gets added to the output path - # e.g. csharp\src\Microsoft.ML.OnnxRuntime\bin\Any CPU\RelWithDebInfo\net6.0-ios\ - # which is inconsistent with the msbuild output path for the pre-.net6 targets - # e.g. csharp\src\Microsoft.ML.OnnxRuntime\bin\RelWithDebInfo\monoandroid11.0 - # and makes it harder to do the packing - # - # 'Any CPU' is the default (first 'mixed' platform specified in the csproj) so this should be fine. - script: | - dotnet build .\src\Microsoft.ML.OnnxRuntime\Microsoft.ML.OnnxRuntime.csproj -p:SelectedTargets=Net6 -p:Configuration=RelWithDebInfo -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=$(OrtPackageId) -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix) + dotnet workload install android ios workingDirectory: '$(Build.SourcesDirectory)\csharp' - task: MSBuild@1 - displayName: 'Restore NuGet Packages and create project.assets.json for pre-.net6 targets' + displayName: 'Restore NuGet Packages and create project.assets.json' inputs: solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.sln' platform: 'Any CPU' configuration: RelWithDebInfo - msbuildArguments: '-t:restore -p:SelectedTargets=PreNet6 -p:OrtPackageId=$(OrtPackageId)' + msbuildArguments: '-t:restore -p:OrtPackageId=$(OrtPackageId)' workingDirectory: '$(Build.SourcesDirectory)\csharp' - task: MSBuild@1 - displayName: 'Build C# for pre-.net6 targets' + displayName: 'Build C# bindings' inputs: solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.sln' platform: 'Any CPU' configuration: RelWithDebInfo - msbuildArguments: '-p:SelectedTargets=PreNet6 -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=$(OrtPackageId) -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix)' + msbuildArguments: '-p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=$(OrtPackageId) -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix)' workingDirectory: '$(Build.SourcesDirectory)\csharp' - ${{ if eq(parameters.DoEsrp, true) }}: @@ -445,15 +430,6 @@ stages: DisplayName: 'ESRP - Sign C# dlls' DoEsrp: ${{ parameters.DoEsrp }} - - task: MSBuild@1 - displayName: Update projects.assets.json with combined list of all target frameworks - inputs: - solution: '$(Build.SourcesDirectory)\csharp\src\Microsoft.ML.OnnxRuntime\Microsoft.ML.OnnxRuntime.csproj' - platform: 'Any CPU' - configuration: RelWithDebInfo - msbuildArguments: '-t:restore -p:SelectedTargets=All -p:OrtPackageId=$(OrtPackageId)' - workingDirectory: '$(Build.SourcesDirectory)\csharp' - - task: MSBuild@1 displayName: 'Build Nuget Packages' inputs: diff --git a/tools/ci_build/github/azure-pipelines/templates/jobs/win-ci-vs-2022-job.yml b/tools/ci_build/github/azure-pipelines/templates/jobs/win-ci-vs-2022-job.yml index 3b1fde6cb6..404699f705 100644 --- a/tools/ci_build/github/azure-pipelines/templates/jobs/win-ci-vs-2022-job.yml +++ b/tools/ci_build/github/azure-pipelines/templates/jobs/win-ci-vs-2022-job.yml @@ -169,7 +169,7 @@ jobs: - task: MSBuild@1 displayName: 'Restore NuGet Packages' inputs: - solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.sln' + solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.DesktopOnly.CSharp.sln' platform: 'Any CPU' configuration: '${{ parameters.BuildConfig }}' msbuildArguments: '-t:restore -p:OrtPackageId=$(OrtPackageId)' @@ -178,7 +178,7 @@ jobs: - task: MSBuild@1 displayName: 'Build C#' inputs: - solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.sln' + solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.DesktopOnly.CSharp.sln' configuration: '${{ parameters.BuildConfig }}' platform: 'Any CPU' msbuildArguments: '-p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=$(OrtPackageId)' @@ -197,7 +197,7 @@ jobs: command: test projects: '$(Build.SourcesDirectory)\csharp\test\Microsoft.ML.OnnxRuntime.Tests.NetCoreApp\Microsoft.ML.OnnxRuntime.Tests.NetCoreApp.csproj' configuration: '${{ parameters.BuildConfig }}' - arguments: '--configuration ${{ parameters.BuildConfig }} -p:Platform="Any CPU" -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=$(OrtPackageId) --blame' + arguments: '--configuration ${{ parameters.BuildConfig }} -p:Platform="Any CPU" -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=$(OrtPackageId) -p:IncludeMobileTargets=false --blame' workingDirectory: '$(Build.SourcesDirectory)\csharp' - ${{ if eq(parameters.EnablePython, true) }}: diff --git a/tools/ci_build/github/azure-pipelines/templates/ondevice-training-cpu-packaging-pipeline.yml b/tools/ci_build/github/azure-pipelines/templates/ondevice-training-cpu-packaging-pipeline.yml index 792e828c9a..24e46066a1 100644 --- a/tools/ci_build/github/azure-pipelines/templates/ondevice-training-cpu-packaging-pipeline.yml +++ b/tools/ci_build/github/azure-pipelines/templates/ondevice-training-cpu-packaging-pipeline.yml @@ -222,44 +222,29 @@ stages: versionSpec: 6.2.1 - task: PowerShell@2 - displayName: Install .NET 6 workloads + displayName: Install mobile workloads inputs: targetType: 'inline' script: | dotnet workload install android workingDirectory: '$(Build.SourcesDirectory)\csharp' - - task: PowerShell@2 - displayName: Build Microsoft.ML.OnnxRuntime .NET 6 targets using dotnet - inputs: - targetType: 'inline' - # we don't specify 'Any CPU' as the platform here because if we do it gets added to the output path - # e.g. csharp\src\Microsoft.ML.OnnxRuntime\bin\Any CPU\RelWithDebInfo\net6.0-ios\ - # which is inconsistent with the msbuild output path for the pre-.net6 targets - # e.g. csharp\src\Microsoft.ML.OnnxRuntime\bin\RelWithDebInfo\monoandroid11.0 - # and makes it harder to do the packing - # - # 'Any CPU' is the default (first 'mixed' platform specified in the csproj) so this should be fine. - script: | - dotnet build .\src\Microsoft.ML.OnnxRuntime\Microsoft.ML.OnnxRuntime.csproj -p:SelectedTargets=Net6 -p:Configuration=RelWithDebInfo -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=$(OrtPackageId) -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }} -p:ReleaseVersionSuffix=$(ReleaseVersionSuffix) - workingDirectory: '$(Build.SourcesDirectory)\csharp' - - task: MSBuild@1 - displayName: 'Restore NuGet Packages and create project.assets.json for pre-.net6 targets' + displayName: 'Restore NuGet Packages and create project.assets.json' inputs: solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.sln' platform: 'Any CPU' configuration: RelWithDebInfo - msbuildArguments: '-t:restore -p:SelectedTargets=PreNet6 -p:OrtPackageId=$(OrtPackageId)' + msbuildArguments: '-t:restore -p:OrtPackageId=$(OrtPackageId)' workingDirectory: '$(Build.SourcesDirectory)\csharp' - task: MSBuild@1 - displayName: 'Build C# for pre-.net6 targets' + displayName: 'Build C# bindings' inputs: solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.sln' platform: 'Any CPU' configuration: RelWithDebInfo - msbuildArguments: '-p:SelectedTargets=PreNet6 -p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=$(OrtPackageId) -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }}' + msbuildArguments: '-p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" -p:OrtPackageId=$(OrtPackageId) -p:IsReleaseBuild=${{ parameters.IsReleaseBuild }}' workingDirectory: '$(Build.SourcesDirectory)\csharp' - ${{ if eq(parameters.DoEsrp, true) }}: @@ -269,15 +254,6 @@ stages: DisplayName: 'ESRP - Sign C# dlls' DoEsrp: ${{ parameters.DoEsrp }} - - task: MSBuild@1 - displayName: Update projects.assets.json with combined list of all target frameworks - inputs: - solution: '$(Build.SourcesDirectory)\csharp\src\Microsoft.ML.OnnxRuntime\Microsoft.ML.OnnxRuntime.csproj' - platform: 'Any CPU' - configuration: RelWithDebInfo - msbuildArguments: '-t:restore -p:SelectedTargets=All -p:OrtPackageId=$(OrtPackageId)' - workingDirectory: '$(Build.SourcesDirectory)\csharp' - - task: MSBuild@1 displayName: 'Build Nuget Packages' inputs: diff --git a/tools/nuget/generate_nuspec_for_native_nuget.py b/tools/nuget/generate_nuspec_for_native_nuget.py index f7b68551b9..df74e7e559 100644 --- a/tools/nuget/generate_nuspec_for_native_nuget.py +++ b/tools/nuget/generate_nuspec_for_native_nuget.py @@ -557,7 +557,7 @@ def generate_files(line_list, args): files_list.append( "' @@ -793,8 +793,10 @@ def generate_files(line_list, args): "" ) - # Some tools to be packaged in nightly build only, should not be released + # Some tools to be packaged in nightly debug build only, should not be released # These are copied to the runtimes folder for convenience of loading with the dlls + # NOTE: nuget gives a spurious error on linux if these aren't in a separate directory to the library so + # we add them to a tools folder for that reason. if ( args.is_release_build.lower() != "true" and args.target_architecture == "x64" @@ -804,7 +806,10 @@ def generate_files(line_list, args): "" ) @@ -817,7 +822,10 @@ def generate_files(line_list, args): "" ) @@ -871,7 +879,6 @@ def generate_files(line_list, args): os.system(copy_command + " " + source_props + " " + target_props) files_list.append("') if not is_snpe_package and not is_qnn_package: - files_list.append("') files_list.append("') # Process targets file @@ -890,7 +897,6 @@ def generate_files(line_list, args): os.system(copy_command + " " + source_targets + " " + target_targets) files_list.append("') if not is_snpe_package and not is_qnn_package: - files_list.append("') files_list.append("') # Process xamarin targets files