diff --git a/csharp/OnnxRuntime.CSharp.proj b/csharp/OnnxRuntime.CSharp.proj index f65c9d1445..fc9fc30740 100644 --- a/csharp/OnnxRuntime.CSharp.proj +++ b/csharp/OnnxRuntime.CSharp.proj @@ -18,6 +18,7 @@ CMake creates a target to this project false false None + false .. @@ -125,7 +126,7 @@ CMake creates a target to this project Properties="NoBuild=true;Platform=AnyCPU;PackageVersion=$(PackageVersion);OrtPackageId=$(OrtPackageId)"/> - + @@ -148,7 +149,7 @@ CMake creates a target to this project - + diff --git a/csharp/src/Microsoft.AI.MachineLearning.Interop/Microsoft.AI.MachineLearning.targets b/csharp/src/Microsoft.AI.MachineLearning.Interop/Microsoft.AI.MachineLearning.targets index 85bc61489d..74a611d67f 100644 --- a/csharp/src/Microsoft.AI.MachineLearning.Interop/Microsoft.AI.MachineLearning.targets +++ b/csharp/src/Microsoft.AI.MachineLearning.Interop/Microsoft.AI.MachineLearning.targets @@ -9,9 +9,11 @@ - $(MSBuildThisFileDirectory)..\..\runtimes\win-$(WindowsAI-Platform)\native\Microsoft.AI.MachineLearning.dll - $(MSBuildThisFileDirectory)..\..\runtimes\win-$(WindowsAI-Platform)\native\onnxruntime.dll - $(MSBuildThisFileDirectory)..\..\runtimes\win-$(WindowsAI-Platform)\native\directml.dll + $(MSBuildThisFileDirectory)..\..\runtimes\win-$(WindowsAI-Platform)\uap + $(MSBuildThisFileDirectory)..\..\runtimes\win-$(WindowsAI-Platform)\native + $(RuntimesDirectory)\Microsoft.AI.MachineLearning.dll + $(RuntimesDirectory)\onnxruntime.dll + $(RuntimesDirectory)\directml.dll @@ -20,7 +22,7 @@ $(WindowsAIBinary);$(OnnxRuntimeBinary);$(DirectMLBinary) - + $(WindowsAIBinary);$(OnnxRuntimeBinary) diff --git a/csharp/src/Microsoft.AI.MachineLearning/Microsoft.AI.MachineLearning.targets b/csharp/src/Microsoft.AI.MachineLearning/Microsoft.AI.MachineLearning.targets index 635165b52f..c578bd7a23 100644 --- a/csharp/src/Microsoft.AI.MachineLearning/Microsoft.AI.MachineLearning.targets +++ b/csharp/src/Microsoft.AI.MachineLearning/Microsoft.AI.MachineLearning.targets @@ -6,19 +6,20 @@ - $(MSBuildThisFileDirectory)..\..\runtimes\win-$(WindowsAI-Platform)\native\Microsoft.AI.MachineLearning.dll - + $(MSBuildThisFileDirectory)..\..\runtimes\win-$(WindowsAI-Platform)\uap + $(MSBuildThisFileDirectory)..\..\runtimes\win-$(WindowsAI-Platform)\native + + $(RuntimesDirectory)\Microsoft.AI.MachineLearning.dll - $(OnnxRuntimePathOverride) - $(MSBuildThisFileDirectory)..\..\runtimes\win-$(WindowsAI-Platform)\native\onnxruntime.dll + $(RuntimesDirectory)\onnxruntime.dll $(DirectMLPathOverride) - $(MSBuildThisFileDirectory)..\..\runtimes\win-$(WindowsAI-Platform)\native\directml.dll + $(RuntimesDirectory)\directml.dll - + $(WindowsAIBinary) @@ -26,7 +27,7 @@ $(WindowsAIBinary);$(OnnxRuntimeBinary);$(DirectMLBinary) - + $(WindowsAIBinary);$(OnnxRuntimeBinary) diff --git a/tools/ci_build/build.py b/tools/ci_build/build.py index 7dcc84cf6b..7493e546d4 100755 --- a/tools/ci_build/build.py +++ b/tools/ci_build/build.py @@ -176,6 +176,9 @@ def parse_arguments(): "--cmake_extra_defines", nargs="+", help="Extra definitions to pass to CMake during build system " "generation. These are just CMake -D options without the leading -D.") + parser.add_argument( + "--target", + help="Build a specific target, e.g. winml_dll") parser.add_argument( "--x86", action='store_true', help="Create x86 makefiles. Requires --update and no existing cache " @@ -893,13 +896,15 @@ def clean_targets(cmake_path, build_dir, configs): run_subprocess(cmd_args) -def build_targets(args, cmake_path, build_dir, configs, parallel): +def build_targets(args, cmake_path, build_dir, configs, parallel, target=None): for config in configs: log.info("Building targets for %s configuration", config) build_dir2 = get_config_build_dir(build_dir, config) cmd_args = [cmake_path, "--build", build_dir2, "--config", config] + if target: + cmd_args.extend(['--target', target]) build_tool_args = [] if parallel: @@ -1506,10 +1511,10 @@ def run_csharp_tests(use_cuda, use_openvino, use_tensorrt, use_dnnl): def build_protoc_for_host(cmake_path, source_dir, build_dir, args): - if (args.arm or args.arm64) and (not is_windows() and not args.ios): + if (args.arm or args.arm64 or args.enable_windows_store) and (not is_windows() and not args.ios): raise BuildError( 'Currently only support building protoc for Windows host while ' - 'cross-compiling for ARM/ARM64 arch and linux cross-compiling iOS') + 'cross-compiling for ARM/ARM64/Store and linux cross-compiling iOS') log.info( "Building protoc for host to be used in cross-compiled build process") @@ -1747,7 +1752,7 @@ def main(): elif is_macOS() and args.use_xcode: cmake_extra_args += ['-G', 'Xcode'] - if (args.android or args.ios) and args.path_to_protoc_exe is None: + if (args.android or args.ios or args.enable_windows_store) and args.path_to_protoc_exe is None: # Cross-compiling for Android and iOS path_to_protoc_exe = build_protoc_for_host( cmake_path, source_dir, build_dir, args) @@ -1776,7 +1781,7 @@ def main(): setup_dml_build(args, cmake_path, build_dir, configs) if args.build: - build_targets(args, cmake_path, build_dir, configs, args.parallel) + build_targets(args, cmake_path, build_dir, configs, args.parallel, args.target) if args.test: run_onnxruntime_tests(args, source_dir, ctest_path, build_dir, configs) diff --git a/tools/ci_build/github/azure-pipelines/nuget/templates/windowsai.yml b/tools/ci_build/github/azure-pipelines/nuget/templates/windowsai.yml index ac78db376c..4b8c5bf095 100644 --- a/tools/ci_build/github/azure-pipelines/nuget/templates/windowsai.yml +++ b/tools/ci_build/github/azure-pipelines/nuget/templates/windowsai.yml @@ -47,58 +47,57 @@ jobs: parameters: BuildArch: 'arm' -- ${{ if eq('false', 'true') }}: - - job: WindowsAI_DirectML_X64_Store - timeoutInMinutes: 120 - workspace: - clean: all - pool: - name: 'Win-GPU-2019' - demands: [] - steps: - - template: ../../templates/windowsai-nuget-build.yml - parameters: - BuildArch: 'x64' - BuildForStore: 'true' +- job: WindowsAI_CPU_X64_Store + timeoutInMinutes: 120 + workspace: + clean: all + pool: + name: 'Win-CPU-2019' + demands: [] + steps: + - template: ../../templates/windowsai-nuget-build.yml + parameters: + BuildArch: 'x64' + BuildForStore: 'true' - - job: WindowsAI_DirectML_X86_Store - timeoutInMinutes: 120 - workspace: - clean: all - pool: - name: 'Win-GPU-2019' - demands: [] - steps: - - template: ../../templates/windowsai-nuget-build.yml - parameters: - BuildArch: 'x86' - BuildForStore: 'true' +- job: WindowsAI_CPU_X86_Store + timeoutInMinutes: 120 + workspace: + clean: all + pool: + name: 'Win-CPU-2019' + demands: [] + steps: + - template: ../../templates/windowsai-nuget-build.yml + parameters: + BuildArch: 'x86' + BuildForStore: 'true' - - job: WindowsAI_CPU_ARM64_Store - timeoutInMinutes: 120 - workspace: - clean: all - pool: - name: 'Win-CPU-2019' - demands: [] - steps: - - template: ../../templates/windowsai-nuget-build.yml - parameters: - BuildArch: 'arm64' - BuildForStore: 'true' - - - job: WindowsAI_CPU_ARM_Store - timeoutInMinutes: 120 - workspace: - clean: all - pool: - name: 'Win-CPU-2019' - demands: [] - steps: - - template: ../../templates/windowsai-nuget-build.yml - parameters: - BuildArch: 'arm' - BuildForStore: 'true' +- job: WindowsAI_CPU_ARM64_Store + timeoutInMinutes: 120 + workspace: + clean: all + pool: + name: 'Win-CPU-2019' + demands: [] + steps: + - template: ../../templates/windowsai-nuget-build.yml + parameters: + BuildArch: 'arm64' + BuildForStore: 'true' + +- job: WindowsAI_CPU_ARM_Store + timeoutInMinutes: 120 + workspace: + clean: all + pool: + name: 'Win-CPU-2019' + demands: [] + steps: + - template: ../../templates/windowsai-nuget-build.yml + parameters: + BuildArch: 'arm' + BuildForStore: 'true' - job: NuGet_Packaging workspace: @@ -109,6 +108,10 @@ jobs: - WindowsAI_DirectML_X86 - WindowsAI_CPU_ARM64 - WindowsAI_CPU_ARM + - WindowsAI_CPU_X64_Store + - WindowsAI_CPU_X86_Store + - WindowsAI_CPU_ARM64_Store + - WindowsAI_CPU_ARM_Store condition: succeeded() steps: - task: DownloadPipelineArtifact@0 @@ -135,6 +138,30 @@ jobs: artifactName: 'Microsoft.AI.MachineLearning.arm' targetPath: '$(Build.BinariesDirectory)/nuget-artifact-arm' + - task: DownloadPipelineArtifact@0 + displayName: 'Download Pipeline Artifact - NuGet DirectML x64 Store' + inputs: + artifactName: 'Microsoft.AI.MachineLearning.x64.Store' + targetPath: '$(Build.BinariesDirectory)/nuget-artifact-x64-store' + + - task: DownloadPipelineArtifact@0 + displayName: 'Download Pipeline Artifact - NuGet DirectML x86 Store' + inputs: + artifactName: 'Microsoft.AI.MachineLearning.x86.Store' + targetPath: '$(Build.BinariesDirectory)/nuget-artifact-x86-store' + + - task: DownloadPipelineArtifact@0 + displayName: 'Download Pipeline Artifact - NuGet CPU ARM64 Store' + inputs: + artifactName: 'Microsoft.AI.MachineLearning.arm64.Store' + targetPath: '$(Build.BinariesDirectory)/nuget-artifact-arm64-store' + + - task: DownloadPipelineArtifact@0 + displayName: 'Download Pipeline Artifact - NuGet CPU ARM Store' + inputs: + artifactName: 'Microsoft.AI.MachineLearning.arm.Store' + targetPath: '$(Build.BinariesDirectory)/nuget-artifact-arm-store' + - task: PowerShell@2 displayName: 'Bundle NuGet and other binaries' inputs: @@ -149,34 +176,72 @@ jobs: $x64_nupkg_unzipped_directory = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory_root, 'binaries', [System.IO.Path]::GetFileNameWithoutExtension($x64_nuget_package)) [System.IO.Compression.ZipFile]::ExtractToDirectory($x64_nuget_package, $x64_nupkg_unzipped_directory) + $nupkgs = (Get-ChildItem ..\nuget-artifact-x64-store -Filter Microsoft.AI.MachineLearning*.nupkg -Recurse) + $x64_store_nuget_package = $nupkgs[0].FullName + $x64_store_nupkg_unzipped_directory_root = $nupkgs[0].Directory.FullName + $x64_store_nupkg_unzipped_directory = [System.IO.Path]::Combine($x64_store_nupkg_unzipped_directory_root, 'binaries', [System.IO.Path]::GetFileNameWithoutExtension($x64_store_nuget_package)) + [System.IO.Compression.ZipFile]::ExtractToDirectory($x64_store_nuget_package, $x64_store_nupkg_unzipped_directory) + $nupkgs = (Get-ChildItem ..\nuget-artifact-x86 -Filter Microsoft.AI.MachineLearning*.nupkg -Recurse) $x86_nuget_package = $nupkgs[0].FullName $x86_nupkg_unzipped_directory_root = $nupkgs[0].Directory.FullName $x86_nupkg_unzipped_directory = [System.IO.Path]::Combine($x86_nupkg_unzipped_directory_root, 'binaries', [System.IO.Path]::GetFileNameWithoutExtension($x86_nuget_package)) [System.IO.Compression.ZipFile]::ExtractToDirectory($x86_nuget_package, $x86_nupkg_unzipped_directory) + $nupkgs = (Get-ChildItem ..\nuget-artifact-x86-store -Filter Microsoft.AI.MachineLearning*.nupkg -Recurse) + $x86_store_nuget_package = $nupkgs[0].FullName + $x86_store_nupkg_unzipped_directory_root = $nupkgs[0].Directory.FullName + $x86_store_nupkg_unzipped_directory = [System.IO.Path]::Combine($x86_store_nupkg_unzipped_directory_root, 'binaries', [System.IO.Path]::GetFileNameWithoutExtension($x86_store_nuget_package)) + [System.IO.Compression.ZipFile]::ExtractToDirectory($x86_store_nuget_package, $x86_store_nupkg_unzipped_directory) + $nupkgs = (Get-ChildItem ..\nuget-artifact-arm64 -Filter Microsoft.AI.MachineLearning*.nupkg -Recurse) $arm64_nuget_package = $nupkgs[0].FullName $arm64_nupkg_unzipped_directory_root = $nupkgs[0].Directory.FullName $arm64_nupkg_unzipped_directory = [System.IO.Path]::Combine($arm64_nupkg_unzipped_directory_root, 'binaries', [System.IO.Path]::GetFileNameWithoutExtension($arm64_nuget_package)) [System.IO.Compression.ZipFile]::ExtractToDirectory($arm64_nuget_package, $arm64_nupkg_unzipped_directory) + $nupkgs = (Get-ChildItem ..\nuget-artifact-arm64-store -Filter Microsoft.AI.MachineLearning*.nupkg -Recurse) + $arm64_store_nuget_package = $nupkgs[0].FullName + $arm64_store_nupkg_unzipped_directory_root = $nupkgs[0].Directory.FullName + $arm64_store_nupkg_unzipped_directory = [System.IO.Path]::Combine($arm64_store_nupkg_unzipped_directory_root, 'binaries', [System.IO.Path]::GetFileNameWithoutExtension($arm64_store_nuget_package)) + [System.IO.Compression.ZipFile]::ExtractToDirectory($arm64_store_nuget_package, $arm64_store_nupkg_unzipped_directory) + $nupkgs = (Get-ChildItem ..\nuget-artifact-arm -Filter Microsoft.AI.MachineLearning*.nupkg -Recurse) $arm_nuget_package = $nupkgs[0].FullName $arm_nupkg_unzipped_directory_root = $nupkgs[0].Directory.FullName $arm_nupkg_unzipped_directory = [System.IO.Path]::Combine($arm_nupkg_unzipped_directory_root, 'binaries', [System.IO.Path]::GetFileNameWithoutExtension($arm_nuget_package)) [System.IO.Compression.ZipFile]::ExtractToDirectory($arm_nuget_package, $arm_nupkg_unzipped_directory) + $nupkgs = (Get-ChildItem ..\nuget-artifact-arm-store -Filter Microsoft.AI.MachineLearning*.nupkg -Recurse) + $arm_store_nuget_package = $nupkgs[0].FullName + $arm_store_nupkg_unzipped_directory_root = $nupkgs[0].Directory.FullName + $arm_store_nupkg_unzipped_directory = [System.IO.Path]::Combine($arm_store_nupkg_unzipped_directory_root, 'binaries', [System.IO.Path]::GetFileNameWithoutExtension($arm_store_nuget_package)) + [System.IO.Compression.ZipFile]::ExtractToDirectory($arm_store_nuget_package, $arm_store_nupkg_unzipped_directory) + + $x64_store_runtime_path_old = [System.IO.Path]::Combine($x64_store_nupkg_unzipped_directory, 'runtimes', 'win-x64', 'uap') + $x64_store_runtime_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'runtimes', 'win-x64', 'uap') $x86_runtime_path_old = [System.IO.Path]::Combine($x86_nupkg_unzipped_directory, 'runtimes', 'win-x86', 'native') $x86_runtime_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'runtimes', 'win-x86', 'native') + $x86_store_runtime_path_old = [System.IO.Path]::Combine($x86_store_nupkg_unzipped_directory, 'runtimes', 'win-x86', 'uap') + $x86_store_runtime_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'runtimes', 'win-x86', 'uap') $arm64_runtime_path_old = [System.IO.Path]::Combine($arm64_nupkg_unzipped_directory, 'runtimes', 'win-arm64', 'native') $arm64_runtime_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'runtimes', 'win-arm64', 'native') + $arm64_store_runtime_path_old = [System.IO.Path]::Combine($arm64_store_nupkg_unzipped_directory, 'runtimes', 'win-arm64', 'uap') + $arm64_store_runtime_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'runtimes', 'win-arm64', 'uap') $arm_runtime_path_old = [System.IO.Path]::Combine($arm_nupkg_unzipped_directory, 'runtimes', 'win-arm', 'native') $arm_runtime_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'runtimes', 'win-arm', 'native') + $arm_store_runtime_path_old = [System.IO.Path]::Combine($arm_store_nupkg_unzipped_directory, 'runtimes', 'win-arm', 'uap') + $arm_store_runtime_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'runtimes', 'win-arm', 'uap') + $uap_build_path_old = [System.IO.Path]::Combine($x64_store_nupkg_unzipped_directory, 'build', 'uap') + $uap_build_path_new = [System.IO.Path]::Combine($x64_nupkg_unzipped_directory, 'build', 'uap') + New-Item -Path $x64_store_runtime_path_new -ItemType Directory New-Item -Path $x86_runtime_path_new -ItemType Directory + New-Item -Path $x86_store_runtime_path_new -ItemType Directory New-Item -Path $arm64_runtime_path_new -ItemType Directory + New-Item -Path $arm64_store_runtime_path_new -ItemType Directory New-Item -Path $arm_runtime_path_new -ItemType Directory + New-Item -Path $arm_store_runtime_path_new -ItemType Directory Copy-Item ([System.IO.Path]::Combine($x86_runtime_path_old, 'onnxruntime.dll')) $x86_runtime_path_new Copy-Item ([System.IO.Path]::Combine($x86_runtime_path_old, 'onnxruntime.lib')) $x86_runtime_path_new @@ -188,12 +253,34 @@ jobs: Copy-Item ([System.IO.Path]::Combine($arm64_runtime_path_old, 'onnxruntime.lib')) $arm64_runtime_path_new Copy-Item ([System.IO.Path]::Combine($arm64_runtime_path_old, 'microsoft.ai.machinelearning.dll')) $arm64_runtime_path_new Copy-Item ([System.IO.Path]::Combine($arm64_runtime_path_old, 'microsoft.ai.machinelearning.lib')) $arm64_runtime_path_new - + Copy-Item ([System.IO.Path]::Combine($arm_runtime_path_old, 'onnxruntime.dll')) $arm_runtime_path_new Copy-Item ([System.IO.Path]::Combine($arm_runtime_path_old, 'onnxruntime.lib')) $arm_runtime_path_new Copy-Item ([System.IO.Path]::Combine($arm_runtime_path_old, 'microsoft.ai.machinelearning.dll')) $arm_runtime_path_new Copy-Item ([System.IO.Path]::Combine($arm_runtime_path_old, 'microsoft.ai.machinelearning.lib')) $arm_runtime_path_new + Copy-Item ([System.IO.Path]::Combine($x64_store_runtime_path_old, 'onnxruntime.dll')) $x64_store_runtime_path_new + Copy-Item ([System.IO.Path]::Combine($x64_store_runtime_path_old, 'onnxruntime.lib')) $x64_store_runtime_path_new + Copy-Item ([System.IO.Path]::Combine($x64_store_runtime_path_old, 'microsoft.ai.machinelearning.dll')) $x64_store_runtime_path_new + Copy-Item ([System.IO.Path]::Combine($x64_store_runtime_path_old, 'microsoft.ai.machinelearning.lib')) $x64_store_runtime_path_new + + Copy-Item ([System.IO.Path]::Combine($x86_store_runtime_path_old, 'onnxruntime.dll')) $x86_store_runtime_path_new + Copy-Item ([System.IO.Path]::Combine($x86_store_runtime_path_old, 'onnxruntime.lib')) $x86_store_runtime_path_new + Copy-Item ([System.IO.Path]::Combine($x86_store_runtime_path_old, 'microsoft.ai.machinelearning.dll')) $x86_store_runtime_path_new + Copy-Item ([System.IO.Path]::Combine($x86_store_runtime_path_old, 'microsoft.ai.machinelearning.lib')) $x86_store_runtime_path_new + + Copy-Item ([System.IO.Path]::Combine($arm64_store_runtime_path_old, 'onnxruntime.dll')) $arm64_store_runtime_path_new + Copy-Item ([System.IO.Path]::Combine($arm64_store_runtime_path_old, 'onnxruntime.lib')) $arm64_store_runtime_path_new + Copy-Item ([System.IO.Path]::Combine($arm64_store_runtime_path_old, 'microsoft.ai.machinelearning.dll')) $arm64_store_runtime_path_new + Copy-Item ([System.IO.Path]::Combine($arm64_store_runtime_path_old, 'microsoft.ai.machinelearning.lib')) $arm64_store_runtime_path_new + + Copy-Item ([System.IO.Path]::Combine($arm_store_runtime_path_old, 'onnxruntime.dll')) $arm_store_runtime_path_new + Copy-Item ([System.IO.Path]::Combine($arm_store_runtime_path_old, 'onnxruntime.lib')) $arm_store_runtime_path_new + Copy-Item ([System.IO.Path]::Combine($arm_store_runtime_path_old, 'microsoft.ai.machinelearning.dll')) $arm_store_runtime_path_new + Copy-Item ([System.IO.Path]::Combine($arm_store_runtime_path_old, 'microsoft.ai.machinelearning.lib')) $arm_store_runtime_path_new + + Copy-Item -Recurse $uap_build_path_old $uap_build_path_new + $merged_nuget_path = [System.IO.Path]::Combine($Env:BUILD_ARTIFACTSTAGINGDIRECTORY, 'merged') if (!(Test-Path $merged_nuget_path)) { New-Item -Path $merged_nuget_path -ItemType Directory diff --git a/tools/ci_build/github/azure-pipelines/templates/windowsai-nuget-build.yml b/tools/ci_build/github/azure-pipelines/templates/windowsai-nuget-build.yml index 4a3e01d048..708d77476b 100644 --- a/tools/ci_build/github/azure-pipelines/templates/windowsai-nuget-build.yml +++ b/tools/ci_build/github/azure-pipelines/templates/windowsai-nuget-build.yml @@ -40,42 +40,74 @@ steps: ${{ if and(eq(parameters.BuildArch, 'x64'), eq(parameters.BuildForStore, 'false')) }}: arguments: '--build_dir $(Build.BinariesDirectory) --skip_submodule_sync --build_shared_lib --enable_onnx_tests --enable_wcos $(TelemetryOption) --use_dml --use_winml --cmake_generator "Visual Studio 16 2019" --update --config RelWithDebInfo --enable_lto --disable_rtti' ${{ if and(eq(parameters.BuildArch, 'x64'), eq(parameters.BuildForStore, 'true')) }}: - arguments: '--build_dir $(Build.BinariesDirectory) --skip_submodule_sync --build_shared_lib --enable_onnx_tests --enable_wcos $(TelemetryOption) --use_dml --use_winml --cmake_generator "Visual Studio 16 2019" --update --config RelWithDebInfo --enable_lto --disable_rtti --enable_windows_store' + arguments: '--build_dir $(Build.BinariesDirectory) --skip_submodule_sync --build_shared_lib --skip_winml_tests --enable_wcos $(TelemetryOption) --use_winml --cmake_generator "Visual Studio 16 2019" --update --config RelWithDebInfo --enable_lto --disable_rtti --enable_windows_store --target winml_dll' ${{ if and(eq(parameters.BuildArch, 'x86'), eq(parameters.BuildForStore, 'false')) }}: arguments: '--build_dir $(Build.BinariesDirectory) --skip_submodule_sync --build_shared_lib --enable_onnx_tests --enable_wcos $(TelemetryOption) --use_dml --use_winml --cmake_generator "Visual Studio 16 2019" --update --config RelWithDebInfo --enable_lto --disable_rtti --x86' ${{ if and(eq(parameters.BuildArch, 'x86'), eq(parameters.BuildForStore, 'true')) }}: - arguments: '--build_dir $(Build.BinariesDirectory) --skip_submodule_sync --build_shared_lib --enable_onnx_tests --enable_wcos $(TelemetryOption) --use_dml --use_winml --cmake_generator "Visual Studio 16 2019" --update --config RelWithDebInfo --enable_lto --disable_rtti --x86 --enable_windows_store' + arguments: '--build_dir $(Build.BinariesDirectory) --skip_submodule_sync --build_shared_lib --skip_winml_tests --enable_wcos $(TelemetryOption) --use_winml --cmake_generator "Visual Studio 16 2019" --update --config RelWithDebInfo --enable_lto --disable_rtti --x86 --enable_windows_store --target winml_dll' ${{ if and(eq(parameters.BuildArch, 'arm64'), eq(parameters.BuildForStore, 'false')) }}: arguments: '--build_dir $(Build.BinariesDirectory) --skip_submodule_sync --build_shared_lib --enable_onnx_tests --enable_wcos $(TelemetryOption) --use_winml --cmake_generator "Visual Studio 16 2019" --update --config RelWithDebInfo --enable_lto --disable_rtti --arm64' ${{ if and(eq(parameters.BuildArch, 'arm64'), eq(parameters.BuildForStore, 'true')) }}: - arguments: '--build_dir $(Build.BinariesDirectory) --skip_submodule_sync --build_shared_lib --enable_onnx_tests --enable_wcos $(TelemetryOption) --use_winml --cmake_generator "Visual Studio 16 2019" --update --config RelWithDebInfo --enable_lto --disable_rtti --arm64 --enable_windows_store' + arguments: '--build_dir $(Build.BinariesDirectory) --skip_submodule_sync --build_shared_lib --skip_winml_tests --enable_wcos $(TelemetryOption) --use_winml --cmake_generator "Visual Studio 16 2019" --update --config RelWithDebInfo --enable_lto --disable_rtti --arm64 --enable_windows_store --target winml_dll' ${{ if and(eq(parameters.BuildArch, 'arm'), eq(parameters.BuildForStore, 'false')) }}: arguments: '--build_dir $(Build.BinariesDirectory) --skip_submodule_sync --build_shared_lib --enable_onnx_tests --enable_wcos $(TelemetryOption) --use_winml --cmake_generator "Visual Studio 16 2019" --update --config RelWithDebInfo --enable_lto --disable_rtti --arm' ${{ if and(eq(parameters.BuildArch, 'arm'), eq(parameters.BuildForStore, 'true')) }}: - arguments: '--build_dir $(Build.BinariesDirectory) --skip_submodule_sync --build_shared_lib --enable_onnx_tests --enable_wcos $(TelemetryOption) --use_winml --cmake_generator "Visual Studio 16 2019" --update --config RelWithDebInfo --enable_lto --disable_rtti --arm --enable_windows_store' + arguments: '--build_dir $(Build.BinariesDirectory) --skip_submodule_sync --build_shared_lib --skip_winml_tests --enable_wcos $(TelemetryOption) --use_winml --cmake_generator "Visual Studio 16 2019" --update --config RelWithDebInfo --enable_lto --disable_rtti --arm --enable_windows_store --target winml_dll' workingDirectory: '$(Build.BinariesDirectory)' - - ${{ if notIn(parameters['sln_platform'], 'Win32', 'x64') }}: + - ${{ if or(notIn(parameters['sln_platform'], 'Win32', 'x64'), eq(parameters.BuildForStore, 'true')) }}: # Use cross-compiled protoc - script: | @echo ##vso[task.setvariable variable=ProtocDirectory]$(Build.BinariesDirectory)\host_protoc\Release - - task: VSBuild@1 - displayName: 'Build' - inputs: - solution: '$(Build.BinariesDirectory)\RelWithDebInfo\onnxruntime.sln' - ${{ if ne(parameters.BuildArch, 'x86') }}: - platform: ${{ parameters.BuildArch }} - ${{ if eq(parameters.BuildArch, 'x86') }}: - platform: 'Win32' - configuration: RelWithDebInfo - msbuildArchitecture: ${{ parameters.BuildArch }} - maximumCpuCount: true - logProjectEvents: true - workingFolder: '$(Build.BinariesDirectory)\RelWithDebInfo' - createLogFile: true + - ${{ if eq(parameters.BuildForStore, 'false') }}: + - task: VSBuild@1 + displayName: 'Build' + inputs: + solution: '$(Build.BinariesDirectory)\RelWithDebInfo\onnxruntime.sln' + ${{ if ne(parameters.BuildArch, 'x86') }}: + platform: ${{ parameters.BuildArch }} + ${{ if eq(parameters.BuildArch, 'x86') }}: + platform: 'Win32' + configuration: RelWithDebInfo + msbuildArchitecture: ${{ parameters.BuildArch }} + maximumCpuCount: true + logProjectEvents: true + workingFolder: '$(Build.BinariesDirectory)\RelWithDebInfo' + createLogFile: true - - ${{ if eq(parameters.BuildArch, 'x64') }}: + - ${{ if eq(parameters.BuildForStore, 'true') }}: + - task: VSBuild@1 + displayName: 'Build' + inputs: + solution: '$(Build.BinariesDirectory)\RelWithDebInfo\onnxruntime.vcxproj' + ${{ if ne(parameters.BuildArch, 'x86') }}: + platform: ${{ parameters.BuildArch }} + ${{ if eq(parameters.BuildArch, 'x86') }}: + platform: 'Win32' + configuration: RelWithDebInfo + msbuildArchitecture: ${{ parameters.BuildArch }} + maximumCpuCount: true + logProjectEvents: true + workingFolder: '$(Build.BinariesDirectory)\RelWithDebInfo' + createLogFile: true + + - task: VSBuild@1 + displayName: 'Build' + inputs: + solution: '$(Build.BinariesDirectory)\RelWithDebInfo\winml_dll.vcxproj' + ${{ if ne(parameters.BuildArch, 'x86') }}: + platform: ${{ parameters.BuildArch }} + ${{ if eq(parameters.BuildArch, 'x86') }}: + platform: 'Win32' + configuration: RelWithDebInfo + msbuildArchitecture: ${{ parameters.BuildArch }} + maximumCpuCount: true + logProjectEvents: true + workingFolder: '$(Build.BinariesDirectory)\RelWithDebInfo' + createLogFile: true + + - ${{ if and(eq(parameters.BuildArch, 'x64'), eq(parameters.BuildForStore, 'false')) }}: - script: | mklink /D /J $(Build.BinariesDirectory)\RelWithDebInfo\models $(Build.BinariesDirectory)\models DIR dist\ /S /B > wheel_filename_file @@ -147,7 +179,7 @@ steps: DoEsrp: 'true' - - ${{ if eq(parameters.BuildArch, 'x64') }}: + - ${{ if and(eq(parameters.BuildArch, 'x64'), eq(parameters.BuildForStore, 'false')) }}: - script: | msbuild $(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj /p:Configuration=RelWithDebInfo /t:CreateWindowsAIPackage /p:OnnxRuntimeBuildDirectory=$(Build.BinariesDirectory) /p:OnnxRuntimeSourceDirectory=$(Build.SourcesDirectory) copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\*.nupkg $(Build.ArtifactStagingDirectory) @@ -155,7 +187,7 @@ steps: workingDirectory: '$(Build.SourcesDirectory)\csharp' displayName: 'Create NuGet Package' - - ${{ if eq(parameters.BuildArch, 'x86') }}: + - ${{ if and(eq(parameters.BuildArch, 'x86'), eq(parameters.BuildForStore, 'false')) }}: - script: | msbuild $(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj /p:Configuration=RelWithDebInfo /t:CreateWindowsAIPackage /p:OnnxRuntimeBuildDirectory=$(Build.BinariesDirectory) /p:OnnxRuntimeSourceDirectory=$(Build.SourcesDirectory) /p:TargetArchitecture=x86 copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\*.nupkg $(Build.ArtifactStagingDirectory) @@ -163,9 +195,25 @@ steps: workingDirectory: '$(Build.SourcesDirectory)\csharp' displayName: 'Create NuGet Package' + - ${{ if and(eq(parameters.BuildArch, 'x64'), eq(parameters.BuildForStore, 'true')) }}: + - script: | + msbuild $(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj /p:Configuration=RelWithDebInfo /t:CreateWindowsAIPackage /p:OnnxRuntimeBuildDirectory=$(Build.BinariesDirectory) /p:OnnxRuntimeSourceDirectory=$(Build.SourcesDirectory) /p:IsStoreBuild=True /p:ProtocDirectory=$(Build.BinariesDirectory)\host_protoc\Release + copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\*.nupkg $(Build.ArtifactStagingDirectory) + copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\*.snupkg $(Build.ArtifactStagingDirectory) + workingDirectory: '$(Build.SourcesDirectory)\csharp' + displayName: 'Create NuGet Package' + + - ${{ if and(eq(parameters.BuildArch, 'x86'), eq(parameters.BuildForStore, 'true')) }}: + - script: | + msbuild $(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj /p:Configuration=RelWithDebInfo /t:CreateWindowsAIPackage /p:OnnxRuntimeBuildDirectory=$(Build.BinariesDirectory) /p:OnnxRuntimeSourceDirectory=$(Build.SourcesDirectory) /p:TargetArchitecture=x86 /p:IsStoreBuild=True /p:ProtocDirectory=$(Build.BinariesDirectory)\host_protoc\Release + copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\*.nupkg $(Build.ArtifactStagingDirectory) + copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\*.snupkg $(Build.ArtifactStagingDirectory) + workingDirectory: '$(Build.SourcesDirectory)\csharp' + displayName: 'Create NuGet Package' + - ${{ if eq(parameters.BuildArch, 'arm64') }}: - script: | - msbuild $(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj /p:Configuration=RelWithDebInfo /t:CreateWindowsAIPackage /p:OnnxRuntimeBuildDirectory=$(Build.BinariesDirectory) /p:OnnxRuntimeSourceDirectory=$(Build.SourcesDirectory) /p:TargetArchitecture=arm64 /p:ProtocDirectory=$(Build.BinariesDirectory)\host_protoc\Release + msbuild $(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj /p:Configuration=RelWithDebInfo /t:CreateWindowsAIPackage /p:OnnxRuntimeBuildDirectory=$(Build.BinariesDirectory) /p:OnnxRuntimeSourceDirectory=$(Build.SourcesDirectory) /p:TargetArchitecture=arm64 /p:IsStoreBuild=${{ parameters.BuildForStore }} /p:ProtocDirectory=$(Build.BinariesDirectory)\host_protoc\Release copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\*.nupkg $(Build.ArtifactStagingDirectory) copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\*.snupkg $(Build.ArtifactStagingDirectory) workingDirectory: '$(Build.SourcesDirectory)\csharp' @@ -173,17 +221,25 @@ steps: - ${{ if eq(parameters.BuildArch, 'arm') }}: - script: | - msbuild $(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj /p:Configuration=RelWithDebInfo /t:CreateWindowsAIPackage /p:OnnxRuntimeBuildDirectory=$(Build.BinariesDirectory) /p:OnnxRuntimeSourceDirectory=$(Build.SourcesDirectory) /p:TargetArchitecture=arm /p:ProtocDirectory=$(Build.BinariesDirectory)\host_protoc\Release + msbuild $(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.proj /p:Configuration=RelWithDebInfo /t:CreateWindowsAIPackage /p:OnnxRuntimeBuildDirectory=$(Build.BinariesDirectory) /p:OnnxRuntimeSourceDirectory=$(Build.SourcesDirectory) /p:TargetArchitecture=arm /p:IsStoreBuild=${{ parameters.BuildForStore }} /p:ProtocDirectory=$(Build.BinariesDirectory)\host_protoc\Release copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\*.nupkg $(Build.ArtifactStagingDirectory) copy $(Build.BinariesDirectory)\RelWithDebInfo\RelWithDebInfo\*.snupkg $(Build.ArtifactStagingDirectory) workingDirectory: '$(Build.SourcesDirectory)\csharp' displayName: 'Create NuGet Package' - - task: PublishPipelineArtifact@0 - displayName: 'Publish Pipeline Artifact: Microsoft.AI.MachineLearning ${{ parameters.BuildArch }}' - inputs: - artifactName: 'Microsoft.AI.MachineLearning.${{ parameters.BuildArch }}' - targetPath: '$(Build.ArtifactStagingDirectory)' + - ${{ if eq(parameters.BuildForStore, 'false') }}: + - task: PublishPipelineArtifact@0 + displayName: 'Publish Pipeline Artifact: Microsoft.AI.MachineLearning ${{ parameters.BuildArch }}' + inputs: + artifactName: 'Microsoft.AI.MachineLearning.${{ parameters.BuildArch }}' + targetPath: '$(Build.ArtifactStagingDirectory)' + + - ${{ if eq(parameters.BuildForStore, 'true') }}: + - task: PublishPipelineArtifact@0 + displayName: 'Publish Pipeline Artifact: Microsoft.AI.MachineLearning ${{ parameters.BuildArch }}' + inputs: + artifactName: 'Microsoft.AI.MachineLearning.${{ parameters.BuildArch }}.Store' + targetPath: '$(Build.ArtifactStagingDirectory)' - task: PublishSymbols@2 displayName: 'Publish Build Symbols' diff --git a/tools/nuget/generate_nuspec_for_native_nuget.py b/tools/nuget/generate_nuspec_for_native_nuget.py index 5ed193cc5f..6fd00f3bc8 100644 --- a/tools/nuget/generate_nuspec_for_native_nuget.py +++ b/tools/nuget/generate_nuspec_for_native_nuget.py @@ -20,6 +20,8 @@ def parse_arguments(): parser.add_argument("--packages_path", required=True, help="Nuget packages output directory.") parser.add_argument("--sources_path", required=True, help="OnnxRuntime source code root.") parser.add_argument("--commit_id", required=True, help="The last commit id included in this package.") + parser.add_argument("--is_store_build", default=False, type=lambda x: x.lower() == 'true', + help="Build for the Microsoft Store") parser.add_argument("--is_release_build", required=False, default=None, type=str, help="Flag indicating if the build is a release build. Accepted values: true/false.") parser.add_argument("--execution_provider", required=False, default='None', type=str, @@ -168,8 +170,8 @@ def generate_files(list, args): includes_cuda = is_cuda_gpu_package or is_cpu_package # Why does the CPU package ship the cuda provider headers? includes_winml = is_windowsai_package - includes_directml = (is_dml_package or is_windowsai_package) and (args.target_architecture == 'x64' - or args.target_architecture == 'x86') + includes_directml = (is_dml_package or is_windowsai_package) and not args.is_store_build and ( + args.target_architecture == 'x64' or args.target_architecture == 'x86') is_windows_build = is_windows() @@ -203,6 +205,10 @@ def generate_files(list, args): copy_command = "cp" runtimes_target = '" target="runtimes\\linux-' + runtimes = '{}{}\\{}"'.format(runtimes_target, + args.target_architecture, + 'uap' if args.is_store_build else 'native') + # Process headers files_list.append('') + '" target="lib\\uap\\Microsoft.AI.MachineLearning.winmd" />') interop_dll = 'Microsoft.AI.MachineLearning.Interop\\netstandard2.0\\Microsoft.AI.MachineLearning.Interop.dll' files_list.append('') @@ -272,12 +278,12 @@ def generate_files(list, args): # Process onnxruntime import lib, dll, and pdb if is_windows_build: files_list.append('') + runtimes + ' />') files_list.append('') + runtimes + ' />') if os.path.exists(os.path.join(args.native_build_path, 'onnxruntime.pdb')): files_list.append('') + runtimes + ' />') else: files_list.append('') + runtimes + ' />') files_list.append('') + runtimes + ' />') files_list.append('') @@ -295,16 +301,19 @@ def generate_files(list, args): # Process microsoft.ai.machinelearning import lib, dll, and pdb files_list.append('') + runtimes_target + args.target_architecture + '\\' + + ('uap' if args.is_store_build else 'native') + + '\\Microsoft.AI.MachineLearning.lib" />') files_list.append('') + runtimes_target + args.target_architecture + '\\' + + ('uap' if args.is_store_build else 'native') + + '\\Microsoft.AI.MachineLearning.dll" />') files_list.append('') + runtimes_target + args.target_architecture + '\\' + + ('uap' if args.is_store_build else 'native') + + '\\Microsoft.AI.MachineLearning.pdb" />') # Process execution providers which are built as shared libs if args.execution_provider == "tensorrt": files_list.append('') + runtimes + ' />') # Process mklml dependency if os.path.exists(os.path.join(args.native_build_path, nuget_dependencies['mklml'])): files_list.append('') + runtimes + ' />') if is_linux() and os.path.exists(os.path.join(args.native_build_path, nuget_dependencies['mklml_1'])): files_list.append('') + runtimes + ' />') # Process libiomp5md dependency if os.path.exists(os.path.join(args.native_build_path, nuget_dependencies['openmp'])): files_list.append('') + runtimes + ' />') # Process tvm dependency if os.path.exists(os.path.join(args.native_build_path, nuget_dependencies['tvm'])): files_list.append('') + runtimes + ' />') # Some tools to be packaged in nightly build only, should not be released # These are copied to the runtimes folder for convenience of loading with the dlls @@ -354,29 +363,29 @@ def generate_files(list, args): os.path.exists(os.path.join(args.native_build_path, nuget_dependencies['onnxruntime_perf_test'])): files_list.append('') + runtimes + ' />') if args.is_release_build.lower() != 'true' and args.target_architecture == 'x64' and \ os.path.exists(os.path.join(args.native_build_path, nuget_dependencies['onnx_test_runner'])): files_list.append('') + runtimes + ' />') # Process props and targets files if is_windowsai_package: windowsai_src = 'Microsoft.AI.MachineLearning' - # Process native props windowsai_props = 'Microsoft.AI.MachineLearning.props' - windowsai_native_props = os.path.join(args.sources_path, 'csharp', 'src', windowsai_src, windowsai_props) - files_list.append('') - # Process native targets windowsai_targets = 'Microsoft.AI.MachineLearning.targets' - windowsai_native_targets = os.path.join(args.sources_path, 'csharp', 'src', windowsai_src, windowsai_targets) - files_list.append('') - # Process native rules + windowsai_native_props = os.path.join(args.sources_path, 'csharp', 'src', windowsai_src, windowsai_props) windowsai_rules = 'Microsoft.AI.MachineLearning.Rules.Project.xml' windowsai_native_rules = os.path.join(args.sources_path, 'csharp', 'src', windowsai_src, windowsai_rules) - files_list.append('') + windowsai_native_targets = os.path.join(args.sources_path, 'csharp', 'src', windowsai_src, windowsai_targets) + build = 'build\\{}'.format('uap' if args.is_store_build else 'native') + files_list.append('') + # Process native targets + files_list.append('') + # Process rules + files_list.append('') # Process .net standard 2.0 targets interop_src = 'Microsoft.AI.MachineLearning.Interop' interop_targets = 'Microsoft.AI.MachineLearning.targets' diff --git a/winml/test/common/std.h b/winml/test/common/std.h index b8435dd327..1a8f132bd7 100644 --- a/winml/test/common/std.h +++ b/winml/test/common/std.h @@ -3,6 +3,8 @@ #pragma once +#define _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING + // stl #include #include @@ -17,4 +19,4 @@ #include #include -#include "test.h" \ No newline at end of file +#include "test.h"