diff --git a/.vscode/launch.json b/.vscode/launch.json index 30eeab2d279..d34884263e6 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,7 +8,7 @@ "name": "Launch", "type": "mono", "request": "launch", - "program": "${workspaceRoot}packages/nunit.consolerunner/3.11.1/tools/nunit3-console.exe ${workspaceRoot}bin/TestDebug/Xamarin.Android.Build.Tests.dll", + "program": "${workspaceRoot}packages/nunit.consolerunner/3.11.1/tools/nunit3-console.exe ${workspaceRoot}bin/TestDebug/net472/Xamarin.Android.Build.Tests.dll", "cwd": "${workspaceRoot}bin/TestDebug/" }, { diff --git a/.vscode/settings.json b/.vscode/settings.json index 0d0f9e6748c..551d332b1b5 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,7 +2,7 @@ "nxunitExplorer.nunit": "packages/nunit.consolerunner/3.11.1/tools/nunit3-console.exe", "nxunitExplorer.modules": [ "bin/TestDebug/MSBuildDeviceIntegration/MSBuildDeviceIntegration.dll", - "bin/TestDebug/Xamarin.Android.Build.Tests.dll", + "bin/TestDebug/net472/Xamarin.Android.Build.Tests.dll", "bin/TestDebug/Xamarin.Android.Build.Tests.Commercial.dll", ], "cmake.configureOnOpen": false diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml index e79384252d2..a9fceb70d05 100644 --- a/build-tools/automation/azure-pipelines.yaml +++ b/build-tools/automation/azure-pipelines.yaml @@ -63,7 +63,7 @@ variables: # - This is a non-fork branch with name containing "mono-" (for Mono bumps) IsMonoBranch: $[and(eq(variables['XA.Commercial.Build'], 'true'), ne(variables['System.PullRequest.IsFork'], 'True'), or(contains(variables['Build.SourceBranchName'], 'mono-'), contains(variables['System.PullRequest.SourceBranch'], 'mono-')))] RunAllTests: $[or(eq(variables['XA.RunAllTests'], true), eq(variables['IsMonoBranch'], true))] - DotNetNUnitCategories: '&& cat != DotNetIgnore && cat != AOT && cat != FSharp && cat != LibraryProjectZip && cat != MkBundle && cat != MonoSymbolicate && cat != PackagesConfig && cat != StaticProject' + DotNetNUnitCategories: '& TestCategory != DotNetIgnore & TestCategory != AOT & TestCategory != FSharp & TestCategory != LibraryProjectZip & TestCategory != MkBundle & TestCategory != MonoSymbolicate & TestCategory != PackagesConfig & TestCategory != StaticProject' # Stage and Job "display names" are shortened because they are combined to form the name of the corresponding GitHub check. stages: @@ -366,7 +366,7 @@ stages: - template: yaml-templates\run-nunit-tests.yaml parameters: testRunTitle: Smoke MSBuild Tests - Windows Build Tree - testAssembly: $(System.DefaultWorkingDirectory)\bin\Test$(XA.Build.Configuration)\Xamarin.Android.Build.Tests.dll + testAssembly: $(System.DefaultWorkingDirectory)\bin\Test$(XA.Build.Configuration)\net472\Xamarin.Android.Build.Tests.dll testResultsFile: TestResult-SmokeMSBuildTests-WinBuildTree-$(XA.Build.Configuration).xml nunitConsoleExtraArgs: --where "cat == SmokeTests" --workers=4 @@ -1054,7 +1054,7 @@ stages: job_name: mac_dotnet_tests_1 job_suffix: One .NET nunit_categories: $(DotNetNUnitCategories) - nunit_extra: --testparam dotnet=true + target_framework: 'netcoreapp3.1' - template: yaml-templates\run-msbuild-mac-tests.yaml parameters: @@ -1062,7 +1062,7 @@ stages: job_name: mac_dotnet_tests_2 job_suffix: One .NET nunit_categories: $(DotNetNUnitCategories) - nunit_extra: --testparam dotnet=true + target_framework: 'netcoreapp3.1' - template: yaml-templates\run-msbuild-mac-tests.yaml parameters: @@ -1070,7 +1070,7 @@ stages: job_name: mac_dotnet_tests_3 job_suffix: One .NET nunit_categories: $(DotNetNUnitCategories) - nunit_extra: --testparam dotnet=true + target_framework: 'netcoreapp3.1' # Xamarin.Android (Test MSBuild - Windows - One .NET) - template: yaml-templates\run-msbuild-win-tests.yaml @@ -1079,7 +1079,7 @@ stages: job_name: win_dotnet_tests_1 job_suffix: One .NET nunit_categories: $(DotNetNUnitCategories) - nunit_extra: --testparam dotnet=true + target_framework: 'netcoreapp3.1' - template: yaml-templates\run-msbuild-win-tests.yaml parameters: @@ -1087,7 +1087,7 @@ stages: job_name: win_dotnet_tests_2 job_suffix: One .NET nunit_categories: $(DotNetNUnitCategories) - nunit_extra: --testparam dotnet=true + target_framework: 'netcoreapp3.1' - template: yaml-templates\run-msbuild-win-tests.yaml parameters: @@ -1095,7 +1095,7 @@ stages: job_name: win_dotnet_tests_3 job_suffix: One .NET nunit_categories: $(DotNetNUnitCategories) - nunit_extra: --testparam dotnet=true + target_framework: 'netcoreapp3.1' - stage: integrated_regression_test displayName: Regression Tests diff --git a/build-tools/automation/yaml-templates/run-msbuild-mac-tests.yaml b/build-tools/automation/yaml-templates/run-msbuild-mac-tests.yaml index a68366b1ffa..c67c8f1d409 100644 --- a/build-tools/automation/yaml-templates/run-msbuild-mac-tests.yaml +++ b/build-tools/automation/yaml-templates/run-msbuild-mac-tests.yaml @@ -5,7 +5,7 @@ parameters: job_name: '' job_suffix: '' nunit_categories: '' - nunit_extra: '' + target_framework: 'net472' run_extra_tests: false jobs: @@ -16,6 +16,8 @@ jobs: cancelTimeoutInMinutes: 5 workspace: clean: all + variables: + UseDotNet: ${{ eq(parameters.target_framework, 'netcoreapp3.1') }} steps: - template: setup-test-environment.yaml @@ -31,24 +33,29 @@ jobs: - template: run-nunit-tests.yaml parameters: + useDotNet: $(UseDotNet) testRunTitle: Xamarin.Android.Build.Tests - macOS-${{ parameters.node_id }} - ${{ parameters.job_suffix }} - testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/Xamarin.Android.Build.Tests.dll - nunitConsoleExtraArgs: --where "cat == Node-${{ parameters.node_id }} ${{ parameters.nunit_categories }}" ${{ parameters.nunit_extra }} + testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/${{ parameters.target_framework }}/Xamarin.Android.Build.Tests.dll + nunitConsoleExtraArgs: --where "cat == Node-${{ parameters.node_id }} ${{ parameters.nunit_categories }}" + dotNetTestExtraArgs: --filter "TestCategory = Node-${{ parameters.node_id }} ${{ parameters.nunit_categories }}" testResultsFile: TestResult-MSBuildTests-${{ parameters.job_name }}-$(XA.Build.Configuration).xml # Only run these tests on node 2 - ${{ if eq(parameters.run_extra_tests, true) }}: - template: run-nunit-tests.yaml parameters: + useDotNet: $(UseDotNet) testRunTitle: Xamarin.Android.Build.Tests.Commercial - macOS testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/Xamarin.Android.Build.Tests.Commercial.dll testResultsFile: TestResult-MSBuildTestsCommercial-macOS-$(XA.Build.Configuration).xml - template: run-nunit-tests.yaml parameters: + useDotNet: $(UseDotNet) testRunTitle: Xamarin.Android.Build.Tests - macOS - No Node - testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/Xamarin.Android.Build.Tests.dll + testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/${{ parameters.target_framework }}/Xamarin.Android.Build.Tests.dll nunitConsoleExtraArgs: --where "cat != Node-1 && cat != Node-2 && cat != Node-3" + dotNetTestExtraArgs: --filter "TestCategory != Node-1 & TestCategory != Node-2 & TestCategory != Node-3" testResultsFile: TestResult-MSBuildTests-macOS-NoNode-$(XA.Build.Configuration).xml - template: upload-results.yaml diff --git a/build-tools/automation/yaml-templates/run-msbuild-win-tests.yaml b/build-tools/automation/yaml-templates/run-msbuild-win-tests.yaml index ec547c801ce..378d8ad5c98 100644 --- a/build-tools/automation/yaml-templates/run-msbuild-win-tests.yaml +++ b/build-tools/automation/yaml-templates/run-msbuild-win-tests.yaml @@ -5,7 +5,7 @@ parameters: job_name: '' job_suffix: '' nunit_categories: '' - nunit_extra: '' + target_framework: 'net472' run_extra_tests: false jobs: @@ -16,6 +16,7 @@ jobs: cancelTimeoutInMinutes: 5 variables: VSINSTALLDIR: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise + UseDotNet: ${{ eq(parameters.target_framework, 'netcoreapp3.1') }} steps: - template: kill-processes.yaml @@ -42,24 +43,29 @@ jobs: # Using all available cores seems to occasionally bog down our machines and cause parallel test execution to slow down dramatically. - template: run-nunit-tests.yaml parameters: + useDotNet: $(UseDotNet) testRunTitle: Xamarin.Android.Build.Tests - Windows-${{ parameters.node_id }} - ${{ parameters.job_suffix }} - testAssembly: $(System.DefaultWorkingDirectory)\bin\Test$(XA.Build.Configuration)\Xamarin.Android.Build.Tests.dll - nunitConsoleExtraArgs: --workers=4 --where "cat == Node-${{ parameters.node_id }} ${{ parameters.nunit_categories }}" ${{ parameters.nunit_extra }} + testAssembly: $(System.DefaultWorkingDirectory)\bin\Test$(XA.Build.Configuration)\${{ parameters.target_framework }}\Xamarin.Android.Build.Tests.dll + nunitConsoleExtraArgs: --workers=4 --where "cat == Node-${{ parameters.node_id }} ${{ parameters.nunit_categories }}" + dotNetTestExtraArgs: --filter "TestCategory = Node-${{ parameters.node_id }} ${{ parameters.nunit_categories }}" testResultsFile: TestResult-MSBuildTests-${{ parameters.job_name }}-$(XA.Build.Configuration).xml # Only run these tests on node 2 - ${{ if eq(parameters.run_extra_tests, true) }}: - template: run-nunit-tests.yaml parameters: + useDotNet: $(UseDotNet) testRunTitle: Xamarin.Android.Build.Tests.Commercial - Windows testAssembly: $(System.DefaultWorkingDirectory)\bin\Test$(XA.Build.Configuration)\Xamarin.Android.Build.Tests.Commercial.dll testResultsFile: TestResult-MSBuildTestsCommercial-Windows-$(XA.Build.Configuration).xml - template: run-nunit-tests.yaml parameters: + useDotNet: $(UseDotNet) testRunTitle: Xamarin.Android.Build.Tests - Windows - No Node - testAssembly: $(System.DefaultWorkingDirectory)\bin\Test$(XA.Build.Configuration)\Xamarin.Android.Build.Tests.dll + testAssembly: $(System.DefaultWorkingDirectory)\bin\Test$(XA.Build.Configuration)\${{ parameters.target_framework }}\Xamarin.Android.Build.Tests.dll nunitConsoleExtraArgs: --workers=4 --where "cat != Node-1 && cat != Node-2 && cat != Node-3" + dotNetTestExtraArgs: --filter "TestCategory != Node-1 & TestCategory != Node-2 & TestCategory != Node-3" testResultsFile: TestResult-MSBuildTests-Windows-NoNode-$(XA.Build.Configuration).xml - template: upload-results.yaml diff --git a/build-tools/automation/yaml-templates/run-nunit-tests.yaml b/build-tools/automation/yaml-templates/run-nunit-tests.yaml index beda4b12131..01cea798797 100644 --- a/build-tools/automation/yaml-templates/run-nunit-tests.yaml +++ b/build-tools/automation/yaml-templates/run-nunit-tests.yaml @@ -3,13 +3,16 @@ parameters: testRunTitle: Xamarin Android Tests testAssembly: [] testResultsFile: TestResult.xml - testResultsFormat: NUnit nunitConsoleExtraArgs: '' + dotNetTestExtraArgs: '' + useDotNet: false condition: succeeded() steps: - powershell: | - if ([Environment]::OSVersion.Platform -eq "Unix") { + if ("${{ parameters.useDotNet }}" -eq $true) { + dotnet test ${{ parameters.testAssembly }} --results-directory . --logger "trx;LogFileName=${{ parameters.testResultsFile }}" ${{ parameters.dotNetTestExtraArgs }} + } elseif ([Environment]::OSVersion.Platform -eq "Unix") { mono ${{ parameters.nunitConsole }} ${{ parameters.testAssembly }} --result ${{ parameters.testResultsFile }} ${{ parameters.nunitConsoleExtraArgs }} } else { ${{ parameters.nunitConsole }} ${{ parameters.testAssembly }} --result ${{ parameters.testResultsFile }} ${{ parameters.nunitConsoleExtraArgs }} @@ -27,7 +30,10 @@ steps: - task: PublishTestResults@2 inputs: - testResultsFormat: ${{ parameters.testResultsFormat }} + ${{ if eq(parameters.useDotNet, true) }}: + testResultsFormat: VSTest + ${{ if ne(parameters.useDotNet, true) }}: + testResultsFormat: NUnit testResultsFiles: ${{ parameters.testResultsFile }} testRunTitle: ${{ parameters.testRunTitle }} condition: ${{ parameters.condition }} diff --git a/build-tools/installers/create-installers.targets b/build-tools/installers/create-installers.targets index e5abae9efd3..5a1405a413b 100644 --- a/build-tools/installers/create-installers.targets +++ b/build-tools/installers/create-installers.targets @@ -121,7 +121,6 @@ <_MSBuildFiles Include="$(MSBuildSrcDir)\cil-strip.pdb" Condition=" '$(PackageId)' != 'Microsoft.Android.Sdk' " /> <_MSBuildFiles Include="$(MSBuildSrcDir)\class-parse.exe" Condition=" '$(PackageId)' != 'Microsoft.Android.Sdk' " /> <_MSBuildFiles Include="$(MSBuildSrcDir)\class-parse.pdb" Condition=" '$(PackageId)' != 'Microsoft.Android.Sdk' " /> - <_MSBuildFiles Include="$(MSBuildSrcDir)\FSharp.Core.dll" /> <_MSBuildFiles Include="$(MSBuildSrcDir)\generator.exe" Condition=" '$(PackageId)' != 'Microsoft.Android.Sdk' " /> <_MSBuildFiles Include="$(MSBuildSrcDir)\generator.pdb" Condition=" '$(PackageId)' != 'Microsoft.Android.Sdk' " /> <_MSBuildFiles Include="$(MSBuildSrcDir)\HtmlAgilityPack.dll" /> diff --git a/build-tools/scripts/MSBuildReferences.projitems b/build-tools/scripts/MSBuildReferences.projitems index 433e2df45e6..4ad98918573 100644 --- a/build-tools/scripts/MSBuildReferences.projitems +++ b/build-tools/scripts/MSBuildReferences.projitems @@ -36,7 +36,7 @@ All - + + + + + + + @@ -26,12 +32,15 @@ + ..\Expected\GenerateDesignerFileExpected.cs PreserveNewest + ..\Expected\GenerateDesignerFileWithElevenStyleableAttributesExpected.cs PreserveNewest + ..\Expected\GenerateDesignerFileWithLibraryReferenceExpected.cs PreserveNewest diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/XamarinAndroidCommonProject.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/XamarinAndroidCommonProject.cs index fe75b631b57..a470605bea3 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/XamarinAndroidCommonProject.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Android/XamarinAndroidCommonProject.cs @@ -1,9 +1,10 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using Microsoft.Build.Construction; -using System.Drawing; +using SixLabors.ImageSharp; +using SixLabors.ImageSharp.Formats; +using SixLabors.ImageSharp.Processing; namespace Xamarin.ProjectTools { @@ -19,22 +20,13 @@ public abstract class XamarinAndroidCommonProject : XamarinAndroidProject BuildItem.Source resourceDesigner; - static byte[] ScaleIcon (Image image, int width, int height) + static byte [] ScaleIcon (Image image, IImageFormat format, int width, int height) { float scale = Math.Min (width / image.Width, height / image.Height); - using (var bmp = new Bitmap ((int)width, (int)height)) { - using (var graphics = Graphics.FromImage (bmp)) { - var scaleWidth = (int)(image.Width * scale); - var scaleHeight = (int)(image.Height * scale); - using (var brush = new SolidBrush (Color.Transparent)) { - graphics.FillRectangle (brush, new RectangleF (0, 0, width, height)); - graphics.DrawImage (image, new Rectangle (((int)width - scaleWidth) / 2, ((int)height - scaleHeight) / 2, scaleWidth, scaleHeight)); - using (var ms = new MemoryStream ()) { - bmp.Save (ms, System.Drawing.Imaging.ImageFormat.Png); - return ms.ToArray (); - } - } - } + using (var ms = new MemoryStream ()) { + var clone = image.Clone (i => i.Resize (width, height)); + clone.Save (ms, format); + return ms.ToArray (); } } @@ -45,11 +37,11 @@ static XamarinAndroidCommonProject () stream.Read (icon_binary_mdpi, 0, (int) stream.Length); stream.Position = 0; - using (var icon = Bitmap.FromStream (stream)) { - icon_binary_hdpi = ScaleIcon (icon, 72, 72); - icon_binary_xhdpi = ScaleIcon (icon, 96, 96); - icon_binary_xxhdpi = ScaleIcon (icon, 144, 144); - icon_binary_xxxhdpi = ScaleIcon (icon, 192, 192); + using (var icon = Image.Load (stream, out var format)) { + icon_binary_hdpi = ScaleIcon (icon, format, 72, 72); + icon_binary_xhdpi = ScaleIcon (icon, format, 96, 96); + icon_binary_xxhdpi = ScaleIcon (icon, format, 144, 144); + icon_binary_xxxhdpi = ScaleIcon (icon, format, 192, 192); } } diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Xamarin.ProjectTools.csproj b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Xamarin.ProjectTools.csproj index 894ed2932ca..4695b00b0b7 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Xamarin.ProjectTools.csproj +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Xamarin.ProjectTools.csproj @@ -81,7 +81,7 @@ - + {E34BCFA0-CAA4-412C-AA1C-75DB8D67D157} diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj index 324927af39c..b4b04585266 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj @@ -35,7 +35,6 @@ - diff --git a/src/Xamarin.Android.Tools.Aidl/Xamarin.Android.Tools.Aidl.csproj b/src/Xamarin.Android.Tools.Aidl/Xamarin.Android.Tools.Aidl.csproj index d06baa32644..1cbdaa539b7 100644 --- a/src/Xamarin.Android.Tools.Aidl/Xamarin.Android.Tools.Aidl.csproj +++ b/src/Xamarin.Android.Tools.Aidl/Xamarin.Android.Tools.Aidl.csproj @@ -1,45 +1,15 @@ - - - - Debug - AnyCPU - {D27AD8F7-7710-40BE-B03B-55EFBEC13C44} - Library - Xamarin.AndroidTools.Aidl - Xamarin.Android.Tools.Aidl - True - + - - False - $(XAInstallPrefix)xbuild\Xamarin\Android - DEBUG; - prompt - 4 - False - - - True + + netstandard2.0 + false $(XAInstallPrefix)xbuild\Xamarin\Android - prompt - 4 - False - - ..\..\bin\$(Configuration)\lib\xamarin.android\xbuild\Xamarin\Android\Xamarin.Android.Cecil.dll - - - - - - - - - +