From a6a23db1303ee77582aff85d13218e4c3e7e64fb Mon Sep 17 00:00:00 2001 From: Sheil Kumar Date: Mon, 14 Dec 2020 15:05:15 -0800 Subject: [PATCH] Enable C# .NET5 for WinML (#6120) * build for .net5 * only reference cswinrt for .net5 * remove netstandard2.0 references * upgrade language version * net5 * remove extra comment closure * add targetframework * set target framework * remove net* * pep8 errors * make test project build with .net windows SDK projection * disable c# builds for non-x64 builds * fix pep8 errors * disable for store build * fix tests * remove cswinrt and sdk references from package * bump cswinrt down to 1.0.1 * fix bin path Co-authored-by: Sheil Kumar --- ...icrosoft.AI.MachineLearning.Interop.csproj | 7 +- .../.gitignore | 0 ...AI.MachineLearning.Tests.DotNet5_0.csproj} | 2 +- ...MachineLearning.Tests.DotNet5_0.csproj.pp} | 2 +- .../NuGet.config | 0 .../NuGet.config.pp | 0 .../Program.cs | 0 .../.gitignore | 4 - ...Learning.Tests.DotNetFramework4_7_2.csproj | 111 ---------------- ...rning.Tests.DotNetFramework4_7_2.csproj.pp | 111 ---------------- ...ineLearning.Tests.DotNetFramework4_7_2.sln | 31 ----- .../NuGet.config | 10 -- .../NuGet.config.pp | 10 -- .../main.cs | 77 ----------- .../packages.config | 6 - .../packages.config.pp | 6 - .../nuget/templates/windowsai.yml | 123 ++++++------------ .../templates/windowsai-nuget-build.yml | 9 +- .../nuget/generate_nuspec_for_native_nuget.py | 41 +++--- 19 files changed, 64 insertions(+), 486 deletions(-) rename csharp/test/{Microsoft.AI.MachineLearning.Tests.DotNetCore3_0 => Microsoft.AI.MachineLearning.Tests.DotNet5_0}/.gitignore (100%) rename csharp/test/{Microsoft.AI.MachineLearning.Tests.DotNetCore3_0/Microsoft.AI.MachineLearning.Tests.DotNetCore3_0.csproj => Microsoft.AI.MachineLearning.Tests.DotNet5_0/Microsoft.AI.MachineLearning.Tests.DotNet5_0.csproj} (90%) rename csharp/test/{Microsoft.AI.MachineLearning.Tests.DotNetCore3_0/Microsoft.AI.MachineLearning.Tests.DotNetCore3_0.csproj.pp => Microsoft.AI.MachineLearning.Tests.DotNet5_0/Microsoft.AI.MachineLearning.Tests.DotNet5_0.csproj.pp} (90%) rename csharp/test/{Microsoft.AI.MachineLearning.Tests.DotNetCore3_0 => Microsoft.AI.MachineLearning.Tests.DotNet5_0}/NuGet.config (100%) rename csharp/test/{Microsoft.AI.MachineLearning.Tests.DotNetCore3_0 => Microsoft.AI.MachineLearning.Tests.DotNet5_0}/NuGet.config.pp (100%) rename csharp/test/{Microsoft.AI.MachineLearning.Tests.DotNetCore3_0 => Microsoft.AI.MachineLearning.Tests.DotNet5_0}/Program.cs (100%) delete mode 100644 csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/.gitignore delete mode 100644 csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2.csproj delete mode 100644 csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2.csproj.pp delete mode 100644 csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2.sln delete mode 100644 csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/NuGet.config delete mode 100644 csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/NuGet.config.pp delete mode 100644 csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/main.cs delete mode 100644 csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/packages.config delete mode 100644 csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/packages.config.pp diff --git a/csharp/src/Microsoft.AI.MachineLearning.Interop/Microsoft.AI.MachineLearning.Interop.csproj b/csharp/src/Microsoft.AI.MachineLearning.Interop/Microsoft.AI.MachineLearning.Interop.csproj index 2918ee1923..ca31e658f8 100644 --- a/csharp/src/Microsoft.AI.MachineLearning.Interop/Microsoft.AI.MachineLearning.Interop.csproj +++ b/csharp/src/Microsoft.AI.MachineLearning.Interop/Microsoft.AI.MachineLearning.Interop.csproj @@ -2,7 +2,7 @@ Microsoft.AI.MachineLearning.Interop - netstandard2.0 + net5.0-windows10.0.19041.0 true Any CPU @@ -12,12 +12,11 @@ $(OnnxRuntimeBuildDirectory)\$(Configuration)\$(Configuration) $(BuildOutputDir)\Microsoft.AI.MachineLearning.Interop $(WindowsAIInteropOutputDir) - 7.3 - - + + diff --git a/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetCore3_0/.gitignore b/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNet5_0/.gitignore similarity index 100% rename from csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetCore3_0/.gitignore rename to csharp/test/Microsoft.AI.MachineLearning.Tests.DotNet5_0/.gitignore diff --git a/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetCore3_0/Microsoft.AI.MachineLearning.Tests.DotNetCore3_0.csproj b/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNet5_0/Microsoft.AI.MachineLearning.Tests.DotNet5_0.csproj similarity index 90% rename from csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetCore3_0/Microsoft.AI.MachineLearning.Tests.DotNetCore3_0.csproj rename to csharp/test/Microsoft.AI.MachineLearning.Tests.DotNet5_0/Microsoft.AI.MachineLearning.Tests.DotNet5_0.csproj index 7ad720a780..4adc09236f 100644 --- a/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetCore3_0/Microsoft.AI.MachineLearning.Tests.DotNetCore3_0.csproj +++ b/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNet5_0/Microsoft.AI.MachineLearning.Tests.DotNet5_0.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.0 + net5.0-windows10.0.19041.0 AnyCPU;x64 diff --git a/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetCore3_0/Microsoft.AI.MachineLearning.Tests.DotNetCore3_0.csproj.pp b/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNet5_0/Microsoft.AI.MachineLearning.Tests.DotNet5_0.csproj.pp similarity index 90% rename from csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetCore3_0/Microsoft.AI.MachineLearning.Tests.DotNetCore3_0.csproj.pp rename to csharp/test/Microsoft.AI.MachineLearning.Tests.DotNet5_0/Microsoft.AI.MachineLearning.Tests.DotNet5_0.csproj.pp index 8b5d03434e..a5d96747bc 100644 --- a/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetCore3_0/Microsoft.AI.MachineLearning.Tests.DotNetCore3_0.csproj.pp +++ b/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNet5_0/Microsoft.AI.MachineLearning.Tests.DotNet5_0.csproj.pp @@ -2,7 +2,7 @@ Exe - netcoreapp3.0 + net5.0-windows10.0.19041.0 AnyCPU;x64 diff --git a/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetCore3_0/NuGet.config b/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNet5_0/NuGet.config similarity index 100% rename from csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetCore3_0/NuGet.config rename to csharp/test/Microsoft.AI.MachineLearning.Tests.DotNet5_0/NuGet.config diff --git a/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetCore3_0/NuGet.config.pp b/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNet5_0/NuGet.config.pp similarity index 100% rename from csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetCore3_0/NuGet.config.pp rename to csharp/test/Microsoft.AI.MachineLearning.Tests.DotNet5_0/NuGet.config.pp diff --git a/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetCore3_0/Program.cs b/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNet5_0/Program.cs similarity index 100% rename from csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetCore3_0/Program.cs rename to csharp/test/Microsoft.AI.MachineLearning.Tests.DotNet5_0/Program.cs diff --git a/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/.gitignore b/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/.gitignore deleted file mode 100644 index b05d286e48..0000000000 --- a/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -# build, distribute, and bins (+ python proto bindings) -Debug -x64 -packages \ No newline at end of file diff --git a/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2.csproj b/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2.csproj deleted file mode 100644 index c3db4b372a..0000000000 --- a/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2.csproj +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - Debug - AnyCPU - {717C645E-9C4A-4EBF-A0AF-676B265E8CDA} - Exe - Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2 - Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2 - v4.7.2 - 512 - true - true - - - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - true - bin\x64\Debug\ - DEBUG;TRACE - full - x64 - 7.3 - prompt - MinimumRecommendedRules.ruleset - true - - - bin\x64\Release\ - TRACE - true - pdbonly - x64 - 7.3 - prompt - MinimumRecommendedRules.ruleset - true - - - - packages\Microsoft.AI.MachineLearning.1.4.0-dev-20200728-0957-6cb93ccb5\lib\netstandard2.0\Microsoft.AI.MachineLearning.Interop.dll - - - packages\Microsoft.Windows.SDK.NET.10.0.18362.3-preview\lib\netstandard2.0\Microsoft.Windows.SDK.NET.dll - - - - - - - - - - - packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200629.3\lib\netstandard2.0\winrt.runtime.dll - - - - - - - - - - - Always - true - - - - - Always - true - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - - \ No newline at end of file diff --git a/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2.csproj.pp b/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2.csproj.pp deleted file mode 100644 index 45ed3d884f..0000000000 --- a/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2.csproj.pp +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - Debug - AnyCPU - {717C645E-9C4A-4EBF-A0AF-676B265E8CDA} - Exe - Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2 - Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2 - v4.7.2 - 512 - true - true - - - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - true - bin\x64\Debug\ - DEBUG;TRACE - full - x64 - 7.3 - prompt - MinimumRecommendedRules.ruleset - true - - - bin\x64\Release\ - TRACE - true - pdbonly - x64 - 7.3 - prompt - MinimumRecommendedRules.ruleset - true - - - - packages\Microsoft.AI.MachineLearning.[PackageVersion]\lib\netstandard2.0\Microsoft.AI.MachineLearning.Interop.dll - - - packages\Microsoft.Windows.SDK.NET.10.0.18362.3-preview\lib\netstandard2.0\Microsoft.Windows.SDK.NET.dll - - - - - - - - - - - packages\Microsoft.Windows.CsWinRT.0.1.0-prerelease.200629.3\lib\netstandard2.0\winrt.runtime.dll - - - - - - - - - - - Always - true - - - - - Always - true - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - - \ No newline at end of file diff --git a/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2.sln b/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2.sln deleted file mode 100644 index c95abf46b0..0000000000 --- a/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.1082 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2", "Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2.csproj", "{717C645E-9C4A-4EBF-A0AF-676B265E8CDA}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|x64 = Debug|x64 - Release|Any CPU = Release|Any CPU - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {717C645E-9C4A-4EBF-A0AF-676B265E8CDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {717C645E-9C4A-4EBF-A0AF-676B265E8CDA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {717C645E-9C4A-4EBF-A0AF-676B265E8CDA}.Debug|x64.ActiveCfg = Debug|x64 - {717C645E-9C4A-4EBF-A0AF-676B265E8CDA}.Debug|x64.Build.0 = Debug|x64 - {717C645E-9C4A-4EBF-A0AF-676B265E8CDA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {717C645E-9C4A-4EBF-A0AF-676B265E8CDA}.Release|Any CPU.Build.0 = Release|Any CPU - {717C645E-9C4A-4EBF-A0AF-676B265E8CDA}.Release|x64.ActiveCfg = Release|x64 - {717C645E-9C4A-4EBF-A0AF-676B265E8CDA}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {4998D043-F471-4AEC-9959-CCE3D27A444E} - EndGlobalSection -EndGlobal diff --git a/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/NuGet.config b/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/NuGet.config deleted file mode 100644 index 246b26a586..0000000000 --- a/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/NuGet.config +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/NuGet.config.pp b/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/NuGet.config.pp deleted file mode 100644 index 7597671d5b..0000000000 --- a/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/NuGet.config.pp +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/main.cs b/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/main.cs deleted file mode 100644 index 3e3910ac3a..0000000000 --- a/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/main.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System; -using System.IO; - -using Microsoft.AI.MachineLearning; -using WinRT; - -namespace Microsoft.AI.MachineLearning.Tests -{ - class Program - { - static void PerformInference(Windows.Media.VideoFrame frame) - { - Console.WriteLine("Load squeezenet.onnx."); - using (var model = Microsoft.AI.MachineLearning.LearningModel.LoadFromFilePath("squeezenet.onnx")) - { - Console.WriteLine("Create LearningModelSession."); - using (var session = new Microsoft.AI.MachineLearning.LearningModelSession(model)) - { - Console.WriteLine("Create LearningModelBinding."); - var binding = new Microsoft.AI.MachineLearning.LearningModelBinding(session); - Console.WriteLine("Bind data_0."); - binding.Bind("data_0", frame); - Console.WriteLine("Evaluate."); - var results = session.Evaluate(binding, ""); - } - Console.WriteLine("Success!\n"); - } - } - static void Main(string[] args) - { - Console.WriteLine("Load kitten_224.png as StorageFile."); - var name = AppDomain.CurrentDomain.BaseDirectory + "kitten_224.png"; - var getFileFromPathTask = Windows.Storage.StorageFile.GetFileFromPathAsync(name); - getFileFromPathTask.AsTask() - .ContinueWith( - (task) => - { - var image = task.Result; - Console.WriteLine("Load StorageFile into Stream."); - var stream_task = image.OpenReadAsync(); - // https://github.com/microsoft/CsWinRT/issues/335 - return stream_task.AsTask().Result; - }) - .ContinueWith( - (task) => - { - using (var stream = task.Result) - { - Console.WriteLine("Create SoftwareBitmap from decoded Stream."); - var decoder_task = Windows.Graphics.Imaging.BitmapDecoder.CreateAsync(stream); - // https://github.com/microsoft/CsWinRT/issues/335 - return decoder_task.AsTask().Result; - } - }) - .ContinueWith( - (task) => - { - var decoder = task.Result; - var software_bitmap_task = decoder.GetSoftwareBitmapAsync(); - // https://github.com/microsoft/CsWinRT/issues/335 - return software_bitmap_task.AsTask().Result; - }) - .ContinueWith( - (task) => - { - using (var software_bitmap = task.Result) - { - Console.WriteLine("Create VideoFrame."); - var frame = Windows.Media.VideoFrame.CreateWithSoftwareBitmap(software_bitmap); - PerformInference(frame); - } - }) - .Wait(); - - } - } -} diff --git a/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/packages.config b/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/packages.config deleted file mode 100644 index b715ddcb76..0000000000 --- a/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/packages.config.pp b/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/packages.config.pp deleted file mode 100644 index fac1ec7a90..0000000000 --- a/csharp/test/Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2/packages.config.pp +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file 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 417138d94d..764539ac65 100644 --- a/tools/ci_build/github/azure-pipelines/nuget/templates/windowsai.yml +++ b/tools/ci_build/github/azure-pipelines/nuget/templates/windowsai.yml @@ -576,89 +576,43 @@ jobs: msbuild /p:Platform=x64 Microsoft.AI.MachineLearning.Tests.vcxproj workingDirectory: $(Build.SourcesDirectory)\csharp\test\Microsoft.AI.MachineLearning.Tests - - task: PowerShell@2 - displayName: 'NuGet Tests: Fix Nuget Package references (.NET FRAMEWORK 4.7.2)' - inputs: - targetType: 'inline' - script: | - Add-Type -AssemblyName "System.IO.Compression.FileSystem" - - $src_root_dir = $Env:BUILD_SOURCESDIRECTORY; - $artifacts_staging_dir = $Env:BUILD_ARTIFACTSTAGINGDIRECTORY; - $merged_nuget_path = [System.IO.Path]::Combine($artifacts_staging_dir, 'merged') - $nupkgs = (Get-ChildItem -Filter Microsoft.AI.MachineLearning*) - $merged_nuget_package = $nupkgs[0] - $merged_nuget_package_name = $merged_nuget_package.Name - $matched_name = ($merged_nuget_package_name -match "Microsoft.AI.MachineLearning.(?.*).nupkg") - $package_version = $matches['version'] - - $src_dir = [System.IO.Path]::Combine($src_root_dir, 'csharp', 'test', 'Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2') - $input_csproj = [System.IO.Path]::Combine($src_dir, 'Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2.csproj.pp') - $csproj = [System.IO.Path]::Combine($src_dir, 'Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2.csproj') - $packages_dir = [System.IO.Path]::Combine($src_dir, 'packages') - $input_csproj_content = Get-Content -Path $input_csproj - $csproj_content = $input_csproj_content -replace '\[PackageVersion\]', $package_version - Set-Content -Path $csproj -Value $csproj_content - - $input_config = [System.IO.Path]::Combine($src_dir, 'packages.config.pp') - $output_config = [System.IO.Path]::Combine($src_dir, 'packages.config') - $input_config_content = Get-Content -Path $input_config - $output_config_content = $input_config_content -replace '\[PackageVersion\]', $package_version - Set-Content -Path $output_config -Value $output_config_content - - nuget restore -PackagesDirectory $packages_dir -Source https://api.nuget.org/v3/index.json -Source $merged_nuget_path $csproj + - task: PowerShell@2 + displayName: 'NuGet Tests: Fix Nuget Package references (.NET 5.0)' + inputs: + targetType: 'inline' + script: | + Add-Type -AssemblyName "System.IO.Compression.FileSystem" + $src_root_dir = $Env:BUILD_SOURCESDIRECTORY; + $artifacts_staging_dir = $Env:BUILD_ARTIFACTSTAGINGDIRECTORY; + $merged_nuget_path = [System.IO.Path]::Combine($artifacts_staging_dir, 'merged') + $nupkgs = (Get-ChildItem -Filter Microsoft.AI.MachineLearning*) + $merged_nuget_package = $nupkgs[0] + $merged_nuget_package_name = $merged_nuget_package.Name + $matched_name = ($merged_nuget_package_name -match "Microsoft.AI.MachineLearning.(?.*).nupkg") + $package_version = $matches['version'] + $src_dir = [System.IO.Path]::Combine($src_root_dir, 'csharp', 'test', 'Microsoft.AI.MachineLearning.Tests.DotNet5_0') + $input_csproj = [System.IO.Path]::Combine($src_dir, 'Microsoft.AI.MachineLearning.Tests.DotNet5_0.csproj.pp') + $csproj = [System.IO.Path]::Combine($src_dir, 'Microsoft.AI.MachineLearning.Tests.DotNet5_0.csproj') + $input_csproj_content = Get-Content -Path $input_csproj + $csproj_content = $input_csproj_content -replace '\[PackageVersion\]', $package_version + Set-Content -Path $csproj -Value $csproj_content + $input_nuget_config = [System.IO.Path]::Combine($src_dir, 'NuGet.config.pp') + $nuget_config = [System.IO.Path]::Combine($src_dir, 'NuGet.config') + $input_nuget_config_content = Get-Content -Path $input_nuget_config + $nuget_config_content = $input_nuget_config_content -replace '\[BuildPackageSource\]', $merged_nuget_path + Set-Content -Path $nuget_config -Value $nuget_config_content workingDirectory: $(Build.ArtifactStagingDirectory)\merged - task: PowerShell@2 - displayName: 'NuGet Tests: Build Tests (C#)' - inputs: - targetType: 'inline' - script: | - msbuild Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2.csproj /p:Platform=AnyCpu - msbuild Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2.csproj /p:Platform=x64 - workingDirectory: $(Build.SourcesDirectory)\csharp\test\Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2 - - - task: PowerShell@2 - displayName: 'NuGet Tests: Fix Nuget Package references (.NET CORE 3.0)' + displayName: 'NuGet Tests: Build Tests (.NET 5.0)' inputs: targetType: 'inline' script: | - Add-Type -AssemblyName "System.IO.Compression.FileSystem" - - $src_root_dir = $Env:BUILD_SOURCESDIRECTORY; - $artifacts_staging_dir = $Env:BUILD_ARTIFACTSTAGINGDIRECTORY; - $merged_nuget_path = [System.IO.Path]::Combine($artifacts_staging_dir, 'merged') - $nupkgs = (Get-ChildItem -Filter Microsoft.AI.MachineLearning*) - $merged_nuget_package = $nupkgs[0] - $merged_nuget_package_name = $merged_nuget_package.Name - $matched_name = ($merged_nuget_package_name -match "Microsoft.AI.MachineLearning.(?.*).nupkg") - $package_version = $matches['version'] - - $src_dir = [System.IO.Path]::Combine($src_root_dir, 'csharp', 'test', 'Microsoft.AI.MachineLearning.Tests.DotNetCore3_0') - $input_csproj = [System.IO.Path]::Combine($src_dir, 'Microsoft.AI.MachineLearning.Tests.DotNetCore3_0.csproj.pp') - $csproj = [System.IO.Path]::Combine($src_dir, 'Microsoft.AI.MachineLearning.Tests.DotNetCore3_0.csproj') - $input_csproj_content = Get-Content -Path $input_csproj - $csproj_content = $input_csproj_content -replace '\[PackageVersion\]', $package_version - Set-Content -Path $csproj -Value $csproj_content - - $input_nuget_config = [System.IO.Path]::Combine($src_dir, 'NuGet.config.pp') - $nuget_config = [System.IO.Path]::Combine($src_dir, 'NuGet.config') - $input_nuget_config_content = Get-Content -Path $input_nuget_config - $nuget_config_content = $input_nuget_config_content -replace '\[BuildPackageSource\]', $merged_nuget_path - Set-Content -Path $nuget_config -Value $nuget_config_content - workingDirectory: $(Build.ArtifactStagingDirectory)\merged - - - - task: PowerShell@2 - displayName: 'NuGet Tests: Build Tests (.NET CORE 3.0)' - inputs: - targetType: 'inline' - script: | - msbuild Microsoft.AI.MachineLearning.Tests.DotNetCore3_0.csproj /p:Platform=x64 /t:Restore - msbuild Microsoft.AI.MachineLearning.Tests.DotNetCore3_0.csproj /p:Platform=x64 - msbuild Microsoft.AI.MachineLearning.Tests.DotNetCore3_0.csproj /p:Platform=AnyCpu /t:Restore - msbuild Microsoft.AI.MachineLearning.Tests.DotNetCore3_0.csproj /p:Platform=AnyCpu - workingDirectory: $(Build.SourcesDirectory)\csharp\test\Microsoft.AI.MachineLearning.Tests.DotNetCore3_0 + msbuild Microsoft.AI.MachineLearning.Tests.DotNet5_0.csproj /p:Platform=x64 /t:Restore + msbuild Microsoft.AI.MachineLearning.Tests.DotNet5_0.csproj /p:Platform=x64 + msbuild Microsoft.AI.MachineLearning.Tests.DotNet5_0.csproj /p:Platform=AnyCpu /t:Restore + msbuild Microsoft.AI.MachineLearning.Tests.DotNet5_0.csproj /p:Platform=AnyCpu + workingDirectory: $(Build.SourcesDirectory)\csharp\test\Microsoft.AI.MachineLearning.Tests.DotNet5_0 - task: PowerShell@2 displayName: 'NuGet Tests: Run Tests' @@ -675,19 +629,16 @@ jobs: .\Microsoft.AI.MachineLearning.Tests.exe popd - Write-Host "Run Microsoft.AI.MachineLearning CSharp Tests (DotNetCore3_0)" - pushd .\Microsoft.AI.MachineLearning.Tests.DotNetCore3_0\bin\x64\Debug\netcoreapp3.0 - .\Microsoft.AI.MachineLearning.Tests.DotNetCore3_0.exe + Write-Host "Run Microsoft.AI.MachineLearning CSharp Tests (DotNet5_0)" + pushd .\Microsoft.AI.MachineLearning.Tests.DotNet5_0\bin\Debug\net5.0-windows10.0.19041.0 + .\Microsoft.AI.MachineLearning.Tests.DotNet5_0.exe popd Write-Host "Run Microsoft.AI.MachineLearning CSharp Tests (AnyCpu)" - pushd .\Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2\bin\Debug - .\Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2.exe - popd - Write-Host "Run Microsoft.AI.MachineLearning CSharp Tests (x64)" - pushd .\Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2\bin\x64\Debug - .\Microsoft.AI.MachineLearning.Tests.DotNetFramework4_7_2.exe + pushd .\Microsoft.AI.MachineLearning.Tests.DotNet5_0\bin\x64\Debug\net5.0-windows10.0.19041.0 + .\Microsoft.AI.MachineLearning.Tests.DotNet5_0.exe popd + Write-Host "Done!" workingDirectory: $(Build.SourcesDirectory)\csharp\test 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 394e3eeb0b..9202f43123 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 @@ -185,10 +185,11 @@ steps: ${{ if eq(parameters.BuildArch, 'arm') }}: arguments: 'x64' modifyEnvironment: true - - - script: msbuild Microsoft.AI.MachineLearning.Interop.csproj /p:Configuration=RelWithDebInfo /p:Platform="Any CPU" /p:OnnxRuntimeBuildDirectory=$(Build.BinariesDirectory) -restore - workingDirectory: '$(Build.SourcesDirectory)\csharp\src\Microsoft.AI.MachineLearning.Interop' - displayName: 'Build Microsoft.AI.MachineLearning.Interop.dll' + + - ${{ if and(eq(parameters.BuildArch, 'x64'), eq(parameters.BuildForStore, 'false')) }}: + - script: msbuild Microsoft.AI.MachineLearning.Interop.csproj /p:Configuration=RelWithDebInfo /p:Platform="Any CPU" /p:OnnxRuntimeBuildDirectory=$(Build.BinariesDirectory) -restore + workingDirectory: '$(Build.SourcesDirectory)\csharp\src\Microsoft.AI.MachineLearning.Interop' + displayName: 'Build Microsoft.AI.MachineLearning.Interop.dll' # Esrp signing - template: win-esrp-dll.yml diff --git a/tools/nuget/generate_nuspec_for_native_nuget.py b/tools/nuget/generate_nuspec_for_native_nuget.py index 935c34ef7e..7fc6dadf3e 100644 --- a/tools/nuget/generate_nuspec_for_native_nuget.py +++ b/tools/nuget/generate_nuspec_for_native_nuget.py @@ -82,19 +82,8 @@ def generate_dependencies(list, package_name, version): list.append('') # Support .Net Core - list.append('') - list.append('') - list.append('') - list.append('') - # Support .Net Standard - list.append('') - list.append('') - list.append('') - list.append('') - # Support .Net Framework - list.append('') - list.append('') - list.append('') + list.append('') + list.append(dml_dependency) list.append('') # UAP10.0.16299, This is the earliest release of the OS that supports .NET Standard apps list.append('') @@ -289,12 +278,15 @@ def generate_files(list, args): files_list.append('') - interop_dll = 'Microsoft.AI.MachineLearning.Interop\\netstandard2.0\\Microsoft.AI.MachineLearning.Interop.dll' - files_list.append('') - interop_pdb = 'Microsoft.AI.MachineLearning.Interop\\netstandard2.0\\Microsoft.AI.MachineLearning.Interop.pdb' - files_list.append('') + if args.target_architecture == 'x64' and not args.is_store_build: + interop_dll_path = 'Microsoft.AI.MachineLearning.Interop\\net5.0-windows10.0.19041.0' + interop_dll = interop_dll_path + '\\Microsoft.AI.MachineLearning.Interop.dll' + files_list.append('') + interop_pdb_path = 'Microsoft.AI.MachineLearning.Interop\\net5.0-windows10.0.19041.0' + interop_pdb = interop_pdb_path + '\\Microsoft.AI.MachineLearning.Interop.pdb' + files_list.append('') # Process runtimes # Process onnxruntime import lib, dll, and pdb @@ -408,11 +400,12 @@ def generate_files(list, args): 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' - windowsai_net20_targets = os.path.join(args.sources_path, 'csharp', 'src', interop_src, interop_targets) - files_list.append('') + # Process .net5.0 targets + if args.target_architecture == 'x64' and not args.is_store_build: + interop_src = 'Microsoft.AI.MachineLearning.Interop' + interop_targets = 'Microsoft.AI.MachineLearning.targets' + windowsai_net50_targets = os.path.join(args.sources_path, 'csharp', 'src', interop_src, interop_targets) + files_list.append('') if is_cpu_package or is_cuda_gpu_package or is_dml_package or is_mklml_package: # Process props file