From 015daae39e1bb529ab783e9a0fc0df5c21d54cac Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Mon, 15 Jun 2020 10:34:26 -0500 Subject: [PATCH] [build] enable One .NET MSBuild tests This will enable all MSBuild tests in `Xamarin.Android.Build.Tests.dll` except for the new categories: `DotNetIgnore`, `AOT`, `FSharp`, `LibraryProjectZip`, `MkBundle`, `MonoSymbolicate`, `PackagesConfig`, and `StaticProject`. Reasoning: * `AOT` - need Mono AOT support in .NET 5. * `FSharp` - [Xamarin.Android.FSharp.ResourceProvider][0] support needed on .NET 5. * `LibraryProjectZip` - will need future support in Xamarin.Android. * `MkBundle` - may not ever come to .NET 5. * `MonoSymbolicate` - need symbolication support in .NET 5. * `PackagesConfig` - n/a for .NET 5. * `StaticProject` a few tests that were migrated to `Xamarin.Android.Build.Tests` in d447aa66 are ignored for now. This also reworks our build pipeline to run the MSBuild tests across 12 CI machines: * Windows - Node 1 - Legacy * Windows - Node 2 - Legacy * Windows - Node 3 - Legacy * Windows - Node 1 - One .NET * Windows - Node 2 - One .NET * Windows - Node 3 - One .NET * macOS - Node 1 - Legacy * macOS - Node 2 - Legacy * macOS - Node 3 - Legacy * macOS - Node 1 - One .NET * macOS - Node 2 - One .NET * macOS - Node 3 - One .NET Since this is a lot of machines: 1. I moved all the `One .NET` tests to their own phase. 2. The phase only runs when `RunAllTests=true`. This means the `One .NET` tests will run on master, release branches, and Mono bumps. You can manually queue a build to enable `RunAllTests` on a PR. To be completed in another PR, there are still more test assemblies that need to be run under a `dotnet` context: * `Xamarin.Android.Build.Tests.Commercial.dll` * `MSBuildDeviceIntegration.dll` [0]: https://github.com/xamarin/Xamarin.Android.FSharp.ResourceProvider --- build-tools/automation/azure-pipelines.yaml | 75 +++++++- .../yaml-templates/run-msbuild-mac-tests.yaml | 26 ++- .../yaml-templates/run-msbuild-win-tests.yaml | 28 ++- .../AndroidUpdateResourcesTest.cs | 43 ++--- .../BindingBuildTest.cs | 25 ++- .../Xamarin.Android.Build.Tests/BuildTest.cs | 168 +++++++++++------- .../CodeBehindTests.cs | 1 + .../EmbeddedDSOTests.cs | 1 + .../EnvironmentContentTests.cs | 2 + .../IncrementalBuildTest.cs | 3 + .../MSBuildSdkExtrasTests.cs | 2 +- .../MakeBundleTests.cs | 2 +- .../ManifestTest.cs | 1 + .../PackagingTest.cs | 113 +++++++----- .../Tasks/LinkerTests.cs | 30 ++-- .../Utilities/BaseTest.cs | 11 ++ .../Xamarin.Android.Build.Tests/XASdkTests.cs | 2 +- .../Tests/XASdkDeployTests.cs | 2 +- 18 files changed, 347 insertions(+), 188 deletions(-) diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml index bfb3375c1a6..e79384252d2 100644 --- a/build-tools/automation/azure-pipelines.yaml +++ b/build-tools/automation/azure-pipelines.yaml @@ -63,6 +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' # Stage and Job "display names" are shortened because they are combined to form the name of the corresponding GitHub check. stages: @@ -796,31 +797,45 @@ stages: - template: yaml-templates/fail-on-issue.yaml - # Xamarin.Android (Test MSBuild - macOS) + # Xamarin.Android (Test MSBuild - macOS - Legacy) - template: yaml-templates\run-msbuild-mac-tests.yaml parameters: node_id: 1 + job_name: mac_msbuild_tests_1 + job_suffix: Legacy - template: yaml-templates\run-msbuild-mac-tests.yaml parameters: node_id: 2 + job_name: mac_msbuild_tests_2 + job_suffix: Legacy + run_extra_tests: true - template: yaml-templates\run-msbuild-mac-tests.yaml parameters: node_id: 3 + job_name: mac_msbuild_tests_3 + job_suffix: Legacy - # Xamarin.Android (Test MSBuild - Windows) + # Xamarin.Android (Test MSBuild - Windows - Legacy) - template: yaml-templates\run-msbuild-win-tests.yaml parameters: node_id: 1 + job_name: win_msbuild_tests_1 + job_suffix: Legacy - template: yaml-templates\run-msbuild-win-tests.yaml parameters: node_id: 2 + job_name: win_msbuild_tests_2 + job_suffix: Legacy + run_extra_tests: true - template: yaml-templates\run-msbuild-win-tests.yaml parameters: node_id: 3 + job_name: win_msbuild_tests_3 + job_suffix: Legacy # Check - "Xamarin.Android (Test MSBuild With Emulator - macOS)" - job: mac_msbuilddevice_tests @@ -1026,6 +1041,62 @@ stages: targetPath: $(Build.ArtifactStagingDirectory)/designer-binlogs condition: always() +- stage: dotnet_tests + displayName: One .NET Tests + dependsOn: mac_build + condition: and(eq(dependencies.mac_build.result, 'Succeeded'), eq(variables['RunAllTests'], true)) + jobs: + + # Xamarin.Android (Test MSBuild - macOS - One .NET) + - template: yaml-templates\run-msbuild-mac-tests.yaml + parameters: + node_id: 1 + job_name: mac_dotnet_tests_1 + job_suffix: One .NET + nunit_categories: $(DotNetNUnitCategories) + nunit_extra: --testparam dotnet=true + + - template: yaml-templates\run-msbuild-mac-tests.yaml + parameters: + node_id: 2 + job_name: mac_dotnet_tests_2 + job_suffix: One .NET + nunit_categories: $(DotNetNUnitCategories) + nunit_extra: --testparam dotnet=true + + - template: yaml-templates\run-msbuild-mac-tests.yaml + parameters: + node_id: 3 + job_name: mac_dotnet_tests_3 + job_suffix: One .NET + nunit_categories: $(DotNetNUnitCategories) + nunit_extra: --testparam dotnet=true + + # Xamarin.Android (Test MSBuild - Windows - One .NET) + - template: yaml-templates\run-msbuild-win-tests.yaml + parameters: + node_id: 1 + job_name: win_dotnet_tests_1 + job_suffix: One .NET + nunit_categories: $(DotNetNUnitCategories) + nunit_extra: --testparam dotnet=true + + - template: yaml-templates\run-msbuild-win-tests.yaml + parameters: + node_id: 2 + job_name: win_dotnet_tests_2 + job_suffix: One .NET + nunit_categories: $(DotNetNUnitCategories) + nunit_extra: --testparam dotnet=true + + - template: yaml-templates\run-msbuild-win-tests.yaml + parameters: + node_id: 3 + job_name: win_dotnet_tests_3 + job_suffix: One .NET + nunit_categories: $(DotNetNUnitCategories) + nunit_extra: --testparam dotnet=true + - stage: integrated_regression_test displayName: Regression Tests dependsOn: mac_build 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 e6b74d6c663..a68366b1ffa 100644 --- a/build-tools/automation/yaml-templates/run-msbuild-mac-tests.yaml +++ b/build-tools/automation/yaml-templates/run-msbuild-mac-tests.yaml @@ -2,10 +2,15 @@ parameters: node_id: 0 + job_name: '' + job_suffix: '' + nunit_categories: '' + nunit_extra: '' + run_extra_tests: false jobs: - - job: mac_msbuild_tests${{ parameters.node_id }} - displayName: MSBuild - Mac-${{ parameters.node_id }} + - job: ${{ parameters.job_name }} + displayName: MSBuild - Mac-${{ parameters.node_id }} - ${{ parameters.job_suffix }} pool: $(HostedMac) timeoutInMinutes: 180 cancelTimeoutInMinutes: 5 @@ -26,13 +31,13 @@ jobs: - template: run-nunit-tests.yaml parameters: - testRunTitle: Xamarin.Android.Build.Tests - macOS-${{ parameters.node_id }} + 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 }}" - testResultsFile: TestResult-MSBuildTests-macOS-Node${{ parameters.node_id }}-$(XA.Build.Configuration).xml + nunitConsoleExtraArgs: --where "cat == Node-${{ parameters.node_id }} ${{ parameters.nunit_categories }}" ${{ parameters.nunit_extra }} + testResultsFile: TestResult-MSBuildTests-${{ parameters.job_name }}-$(XA.Build.Configuration).xml # Only run these tests on node 2 - - ${{ if eq(parameters.node_id, 2) }}: + - ${{ if eq(parameters.run_extra_tests, true) }}: - template: run-nunit-tests.yaml parameters: testRunTitle: Xamarin.Android.Build.Tests.Commercial - macOS @@ -46,15 +51,8 @@ jobs: nunitConsoleExtraArgs: --where "cat != Node-1 && cat != Node-2 && cat != Node-3" testResultsFile: TestResult-MSBuildTests-macOS-NoNode-$(XA.Build.Configuration).xml - - template: run-nunit-tests.yaml - parameters: - testRunTitle: Xamarin.Android.Build.Tests - macOS - One .NET - testAssembly: $(System.DefaultWorkingDirectory)/bin/Test$(XA.Build.Configuration)/Xamarin.Android.Build.Tests.dll - nunitConsoleExtraArgs: --where "cat == dotnet" --params dotnet=true - testResultsFile: TestResult-MSBuildTests-macOS-dotnet-$(XA.Build.Configuration).xml - - template: upload-results.yaml parameters: - artifactName: Test Results - MSBuild - Mac-${{ parameters.node_id }} + artifactName: Test Results - MSBuild - Mac-${{ parameters.node_id }} - ${{ parameters.job_suffix }} - template: fail-on-issue.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 795b9580364..ec547c801ce 100644 --- a/build-tools/automation/yaml-templates/run-msbuild-win-tests.yaml +++ b/build-tools/automation/yaml-templates/run-msbuild-win-tests.yaml @@ -2,10 +2,15 @@ parameters: node_id: 0 + job_name: '' + job_suffix: '' + nunit_categories: '' + nunit_extra: '' + run_extra_tests: false jobs: - - job: win_msbuild_tests${{ parameters.node_id }} - displayName: MSBuild - Windows-${{ parameters.node_id }} + - job: ${{ parameters.job_name }} + displayName: MSBuild - Windows-${{ parameters.node_id }} - ${{ parameters.job_suffix }} pool: $(VSEngWinVS2019) timeoutInMinutes: 180 cancelTimeoutInMinutes: 5 @@ -37,13 +42,13 @@ 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: - testRunTitle: Xamarin.Android.Build.Tests - Windows-${{ parameters.node_id }} + 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 }}" - testResultsFile: TestResult-MSBuildTests-Windows-Node${{ parameters.node_id }}-$(XA.Build.Configuration).xml + nunitConsoleExtraArgs: --workers=4 --where "cat == Node-${{ parameters.node_id }} ${{ parameters.nunit_categories }}" ${{ parameters.nunit_extra }} + testResultsFile: TestResult-MSBuildTests-${{ parameters.job_name }}-$(XA.Build.Configuration).xml # Only run these tests on node 2 - - ${{ if eq(parameters.node_id, 2) }}: + - ${{ if eq(parameters.run_extra_tests, true) }}: - template: run-nunit-tests.yaml parameters: testRunTitle: Xamarin.Android.Build.Tests.Commercial - Windows @@ -55,17 +60,10 @@ jobs: testRunTitle: Xamarin.Android.Build.Tests - Windows - No Node testAssembly: $(System.DefaultWorkingDirectory)\bin\Test$(XA.Build.Configuration)\Xamarin.Android.Build.Tests.dll nunitConsoleExtraArgs: --workers=4 --where "cat != Node-1 && cat != Node-2 && cat != Node-3" - testResultsFile: TestResult-MSBuildTests-Windows-Node${{ parameters.node_id }}-$(XA.Build.Configuration).xml - - - template: run-nunit-tests.yaml - parameters: - testRunTitle: Xamarin.Android.Build.Tests - Windows - One .NET - testAssembly: $(System.DefaultWorkingDirectory)\bin\Test$(XA.Build.Configuration)\Xamarin.Android.Build.Tests.dll - nunitConsoleExtraArgs: --workers=4 --where "cat == dotnet" --params dotnet=true - testResultsFile: TestResult-MSBuildTests-Windows-dotnet-$(XA.Build.Configuration).xml + testResultsFile: TestResult-MSBuildTests-Windows-NoNode-$(XA.Build.Configuration).xml - template: upload-results.yaml parameters: - artifactName: Test Results - MSBuild - Windows-${{ parameters.node_id }} + artifactName: Test Results - MSBuild - Windows-${{ parameters.node_id }} - ${{ parameters.job_suffix }} - template: fail-on-issue.yaml diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidUpdateResourcesTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidUpdateResourcesTest.cs index d637f3a3529..025deb47e71 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidUpdateResourcesTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidUpdateResourcesTest.cs @@ -17,17 +17,6 @@ namespace Xamarin.Android.Build.Tests [Parallelizable (ParallelScope.Children)] public class AndroidUpdateResourcesTest : BaseTest { - string GetResourceDesignerPath (ProjectBuilder builder, XamarinAndroidProject project) - { - string path; - if (Builder.UseDotNet) { - path = Path.Combine (Root, builder.ProjectDirectory, project.IntermediateOutputPath); - } else { - path = Path.Combine (Root, builder.ProjectDirectory, "Resources"); - } - return Path.Combine (path, "Resource.designer" + project.Language.DefaultDesignerExtension); - } - [Test] [Category ("dotnet")] public void CheckMultipleLibraryProjectReferenceAlias ([Values (true, false)] bool withGlobal) @@ -183,9 +172,11 @@ public void CheckEmbeddedSupportLibraryResources () KnownPackages.AndroidSupportV4_27_0_2_1, KnownPackages.SupportV7AppCompat_27_0_2_1, }, - TargetFrameworkVersion = "v7.1", }; - using (var b = CreateApkBuilder ("temp/CheckEmbeddedSupportLibraryResources")) { + if (Builder.UseDotNet) { + proj.AddDotNetCompatPackages (); + } + using (var b = CreateApkBuilder ()) { Assert.IsTrue (b.Build (proj), "First build should have succeeded."); var Rdrawable = b.Output.GetIntermediaryPath (Path.Combine ("android", "bin", "classes", "android", "support", "v7", "appcompat", "R$drawable.class")); Assert.IsTrue (File.Exists (Rdrawable), $"{Rdrawable} should exist"); @@ -292,6 +283,7 @@ public void RepetiviteBuildUpdateSingleResource ([Values (false, true)] bool use [Test] [NonParallelizable] + [Category ("DotNetIgnore")] // task is built for net45 public void Check9PatchFilesAreProcessed () { var projectPath = Path.Combine ("temp", "Check9PatchFilesAreProcessed"); @@ -561,6 +553,9 @@ public void CheckResourceDesignerIsCreated (bool isRelease, ProjectLanguage lang if (IsWindows && isFSharp) { Assert.Ignore ("Skipping this F# test on Windows."); } + if (Builder.UseDotNet && isFSharp) { + Assert.Ignore ("Skipping this F# test under 'dotnet'."); + } var proj = new XamarinAndroidApplicationProject () { Language = language, @@ -589,9 +584,13 @@ public void CheckResourceDesignerIsUpdatedWhenReadOnly (bool isRelease, ProjectL { //Due to the MSBuild project automatically sorting , we can't possibly get the F# projects to build here on Windows // This API is sorting them: https://github.com/xamarin/xamarin-android/blob/c588bfe07aab224c97996a264579f4d4f18a151c/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/DotNetXamarinProject.cs#L117 - if (IsWindows && language == XamarinAndroidProjectLanguage.FSharp) { + bool isFSharp = language == XamarinAndroidProjectLanguage.FSharp; + if (IsWindows && isFSharp) { Assert.Ignore ("Skipping this F# test on Windows."); } + if (Builder.UseDotNet && isFSharp) { + Assert.Ignore ("Skipping this F# test under 'dotnet'."); + } var proj = new XamarinAndroidApplicationProject () { Language = language, @@ -599,7 +598,7 @@ public void CheckResourceDesignerIsUpdatedWhenReadOnly (bool isRelease, ProjectL }; using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) { Assert.IsTrue (b.Build (proj), "Build should have succeeded."); - var designerPath = Path.Combine (Root, b.ProjectDirectory, "Resources", "Resource.designer" + proj.Language.DefaultDesignerExtension); + var designerPath = GetResourceDesignerPath (b, proj); var attr = File.GetAttributes (designerPath); File.SetAttributes (designerPath, FileAttributes.ReadOnly); Assert.IsTrue ((File.GetAttributes (designerPath) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly, @@ -629,13 +628,9 @@ public void CheckResourceDesignerIsUpdatedWhenReadOnly (bool isRelease, ProjectL } [Test] - [TestCaseSource(nameof (ReleaseLanguage))] - public void CheckOldResourceDesignerIsNotUsed (bool isRelease, ProjectLanguage language) + public void CheckOldResourceDesignerIsNotUsed ([Values (true, false)] bool isRelease) { - if (language == XamarinAndroidProjectLanguage.FSharp) - Assert.Ignore ("Skipping CheckOldResourceDesignerIsNotUsed for FSharp until Xamarin.Android.FSharp.ResourceProvider supports it."); var proj = new XamarinAndroidApplicationProject () { - Language = language, IsRelease = isRelease, }; proj.SetProperty ("AndroidUseIntermediateDesignerFile", "True"); @@ -660,13 +655,9 @@ public void CheckOldResourceDesignerIsNotUsed (bool isRelease, ProjectLanguage l // ref https://bugzilla.xamarin.com/show_bug.cgi?id=30089 [Test] - [TestCaseSource(nameof (ReleaseLanguage))] - public void CheckOldResourceDesignerWithWrongCasingIsRemoved (bool isRelease, ProjectLanguage language) + public void CheckOldResourceDesignerWithWrongCasingIsRemoved ([Values (true, false)] bool isRelease) { - if (language == XamarinAndroidProjectLanguage.FSharp) - Assert.Ignore ("Skipping CheckOldResourceDesignerIsNotUsed for FSharp until Xamarin.Android.FSharp.ResourceProvider supports it."); var proj = new XamarinAndroidApplicationProject () { - Language = language, IsRelease = isRelease, }; proj.SetProperty ("AndroidUseIntermediateDesignerFile", "True"); @@ -1100,6 +1091,7 @@ public void BuildAppWithManagedResourceParserAndLibraries () } [Test] + [Category ("DotNetIgnore")] // n/a in .NET 5, not possible to use $(TFV) of v8.0 public void CheckMaxResWarningIsEmittedAsAWarning([Values (false, true)] bool useAapt2) { var path = Path.Combine ("temp", TestName); @@ -1301,6 +1293,7 @@ public void CustomViewAddResourceId ([Values (false, true)] bool useAapt2) // https://github.com/xamarin/xamarin-android/issues/2205 [Test] [NonParallelizable] + [Category ("DotNetIgnore")] // task is built for net45 public void Issue2205 ([Values (false, true)] bool useAapt2) { var proj = new XamarinAndroidApplicationProject (); diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BindingBuildTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BindingBuildTest.cs index edb5846b12d..dd18c353735 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BindingBuildTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BindingBuildTest.cs @@ -25,14 +25,17 @@ public class BindingBuildTest : BaseTest { public void BuildBasicBindingLibrary (string classParser) { var targets = new List { - "_ExtractJavaDocJars", "_ExportJarToXml", "GenerateBindings", "_CreateBindingResourceArchive", - "BuildDocumentation", "_ResolveLibraryProjectImports", "CoreCompile", }; + if (!Builder.UseDotNet) { + //TODO: .NET 5+ cannot support javadoc yet, due to missing mdoc + targets.Add ("_ExtractJavaDocJars"); + targets.Add ("BuildDocumentation"); + } var proj = new XamarinAndroidBindingProject () { IsRelease = true, @@ -82,7 +85,9 @@ public void CleanBasicBindingLibrary (string classParser) }; var files = Directory.GetFiles (Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath), "*", SearchOption.AllDirectories) .Where (x => !ignoreFiles.Any (i => !Path.GetFileName (x).Contains (i))); - Assert.AreEqual (0, Directory.GetDirectories (Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath), "*", SearchOption.AllDirectories).Length, + var directories = Directory.GetDirectories (Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath), "*", SearchOption.AllDirectories) + .Where (x => Path.GetFileName (x) != "designtime"); + Assert.AreEqual (0, directories.Count (), "All directories in {0} should have been removed", proj.IntermediateOutputPath); Assert.AreEqual (0, files.Count (), "{0} should be empty. Found {1}", proj.IntermediateOutputPath, string.Join (Environment.NewLine, files)); @@ -91,6 +96,7 @@ public void CleanBasicBindingLibrary (string classParser) [Test] [TestCaseSource (nameof (ClassParseOptions))] + [Category ("LibraryProjectZip")] public void BuildAarBindigLibraryStandalone (string classParser) { var proj = new XamarinAndroidBindingProject () { @@ -109,6 +115,7 @@ public void BuildAarBindigLibraryStandalone (string classParser) [Test] [TestCaseSource (nameof (ClassParseOptions))] + [Category ("LibraryProjectZip")] public void BuildAarBindigLibraryWithNuGetPackageOfJar (string classParser) { var proj = new XamarinAndroidBindingProject () { @@ -135,7 +142,7 @@ public void BuildAarBindigLibraryWithNuGetPackageOfJar (string classParser) [Test] [TestCaseSource (nameof (ClassParseOptions))] [NonParallelizable] - [Category ("SmokeTests")] + [Category ("SmokeTests"), Category ("LibraryProjectZip")] public void BuildLibraryZipBindigLibraryWithAarOfJar (string classParser) { var proj = new XamarinAndroidBindingProject () { @@ -209,6 +216,7 @@ public void BindByteArrayInMethodParameter () } [Test] + [Category ("LibraryProjectZip")] public void MergeAndroidManifest () { var binding = new XamarinAndroidBindingProject () { @@ -239,6 +247,7 @@ public void MergeAndroidManifest () } [Test] + [Category ("LibraryProjectZip")] public void AnnotationSupport () { // https://trello.com/c/a36dDVS6/37-support-for-annotations-zip @@ -261,6 +270,7 @@ public void BindingCustomJavaApplicationClass () { var binding = new XamarinAndroidBindingProject () { IsRelease = true, + ProjectName = "Binding", }; binding.AndroidClassParser = "class-parse"; @@ -269,7 +279,7 @@ public void BindingCustomJavaApplicationClass () binding.Jars.Add (new AndroidItem.EmbeddedJar (() => multidexJar)); bindingBuilder.Build (binding); var proj = new XamarinAndroidApplicationProject (); - proj.OtherBuildItems.Add (new BuildItem ("ProjectReference", "..\\MultiDexBinding\\UnnamedProject.csproj")); + proj.OtherBuildItems.Add (new BuildItem ("ProjectReference", $"..\\MultiDexBinding\\{binding.ProjectName}.csproj")); using (var b = CreateApkBuilder ("temp/BindingCustomJavaApplicationClass/App")) { b.Verbosity = Microsoft.Build.Framework.LoggerVerbosity.Diagnostic; Assert.IsTrue (b.Build (proj), "Build should have succeeded."); @@ -278,6 +288,7 @@ public void BindingCustomJavaApplicationClass () } [Test] + [Category ("LibraryProjectZip")] public void BindngFilterUnsupportedNativeAbiLibraries () { var binding = new XamarinAndroidBindingProject () { @@ -298,6 +309,7 @@ public void BindngFilterUnsupportedNativeAbiLibraries () } [Test] + [Category ("LibraryProjectZip")] public void BindingCheckHiddenFiles () { var binding = new XamarinAndroidBindingProject () { @@ -395,6 +407,7 @@ public void OnUpdate (Java.Lang.Object p0) } [Test] + [Category ("LibraryProjectZip")] public void RemoveEventHandlerResolution () { var binding = new XamarinAndroidBindingProject () { @@ -469,6 +482,7 @@ static Version GetJdkVersion () [Test] [TestCaseSource (nameof (ClassParseOptions))] + [Category ("LibraryProjectZip")] public void DesignTimeBuild (string classParser) { var proj = new XamarinAndroidBindingProject { @@ -556,6 +570,7 @@ public void BindDefaultInterfaceMethods (string classParser) } [Test] + [Category ("LibraryProjectZip")] public void BugzillaBug11964 () { var proj = new XamarinAndroidBindingProject (); diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs index cf2f7907782..66f42c1f982 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs @@ -48,7 +48,7 @@ public void BuildBasicApplication ([Values (true, false)] bool isRelease) } [Test] - [Category ("SmokeTests")] + [Category ("SmokeTests"), Category ("AOT")] public void BuildBasicApplicationReleaseProfiledAot () { var proj = new XamarinAndroidApplicationProject () { @@ -63,7 +63,7 @@ public void BuildBasicApplicationReleaseProfiledAot () } } - [Test] + [Test, Category ("AOT")] public void BuildBasicApplicationReleaseProfiledAotWithoutDefaultProfile () { var proj = new XamarinAndroidApplicationProject () { @@ -195,7 +195,7 @@ static void Test () } [Test] - [Category ("Minor")] + [Category ("Minor"), Category ("FSharp")] [NonParallelizable] // parallel NuGet restore causes failures public void BuildBasicApplicationFSharp ([Values (true, false)] bool isRelease) { @@ -212,6 +212,10 @@ public void BuildBasicApplicationFSharp ([Values (true, false)] bool isRelease) [NonParallelizable] public void BuildBasicApplicationAppCompat ([Values (true, false)] bool usePackageReference) { + if (Builder.UseDotNet && !usePackageReference) { + Assert.Ignore ("'packages.config' is not supported in .NET 5+."); + } + var proj = new XamarinAndroidApplicationProject (); var packages = usePackageReference ? proj.PackageReferences : proj.Packages; packages.Add (KnownPackages.SupportV7AppCompat_27_0_2_1); @@ -269,6 +273,7 @@ public void AndroidXMigration ([Values (true, false)] bool isRelease) } [Test] + [Category ("PackagesConfig")] public void DuplicateReferences () { var proj = new XamarinAndroidApplicationProject (); @@ -328,7 +333,7 @@ public void DuplicateRJavaOutput () } [Test] - [Category ("SmokeTests")] + [Category ("SmokeTests"), Category ("DotNetIgnore")] // task is built for net45] [NonParallelizable] // parallel NuGet restore causes failures public void BuildXamarinFormsMapsApplication ([Values (true, false)] bool multidex) { @@ -390,7 +395,8 @@ public void SkipConvertResourcesCases ([Values (false, true)] bool useAapt2) List skipped = new List (), processed = new List (); bool convertResourcesCases = false; - foreach (var line in b.LastBuildOutput) { + foreach (var text in b.LastBuildOutput) { + var line = text.Trim (); if (!convertResourcesCases) { convertResourcesCases = line.StartsWith ($"Task \"{target}\"", StringComparison.OrdinalIgnoreCase); } else if (line.StartsWith ($"Done executing task \"{target}\"", StringComparison.OrdinalIgnoreCase)) { @@ -420,17 +426,19 @@ public void SkipConvertResourcesCases ([Values (false, true)] bool useAapt2) Assert.IsTrue (processed.ContainsText (resource), $"`{target}` should process `{resource}`."); } - var files = new [] { - "Xamarin.Android.Support.Compat.dll", - "Xamarin.Android.Support.Design.dll", - "Xamarin.Android.Support.Media.Compat.dll", - "Xamarin.Android.Support.Transition.dll", - "Xamarin.Android.Support.v7.AppCompat.dll", - "Xamarin.Android.Support.v7.CardView.dll", - "Xamarin.Android.Support.v7.MediaRouter.dll", - "Xamarin.Android.Support.v7.RecyclerView.dll", + var files = new List { "material-menu-1.1.0.aar", }; + if (!Builder.UseDotNet) { + files.Add ("Xamarin.Android.Support.Compat.dll"); + files.Add ("Xamarin.Android.Support.Design.dll"); + files.Add ("Xamarin.Android.Support.Media.Compat.dll"); + files.Add ("Xamarin.Android.Support.Transition.dll"); + files.Add ("Xamarin.Android.Support.v7.AppCompat.dll"); + files.Add ("Xamarin.Android.Support.v7.CardView.dll"); + files.Add ("Xamarin.Android.Support.v7.MediaRouter.dll"); + files.Add ("Xamarin.Android.Support.v7.RecyclerView.dll"); + } foreach (var file in files) { Assert.IsTrue (StringAssertEx.ContainsText (skipped, file), $"`{target}` should skip `{file}`."); } @@ -486,6 +494,7 @@ public void CheckKeystoreIsCreated () } [Test] + [Category ("FSharp")] [NonParallelizable] // parallel NuGet restore causes failures public void FSharpAppHasAndroidDefine () { @@ -659,6 +668,7 @@ public void AndroidResourceNotExist () } [Test] + [Category ("DotNetIgnore")] // n/a for .NET 5+ public void TargetFrameworkMonikerAssemblyAttributesPath () { const string filePattern = "MonoAndroid,Version=v*.AssemblyAttributes.cs"; @@ -822,11 +832,15 @@ public void BuildApplicationWithLibraryAndClean ([Values (false, true)] bool isR public void BuildIncrementingAssemblyVersion () { var proj = new XamarinAndroidApplicationProject (); + if (Builder.UseDotNet) { + proj.SetProperty ("GenerateAssemblyInfo", "false"); + proj.SetProperty ("Deterministic", "false"); // Required for AssemblyVersion wildcards + } proj.Sources.Add (new BuildItem ("Compile", "AssemblyInfo.cs") { TextContent = () => "[assembly: System.Reflection.AssemblyVersion (\"1.0.0.*\")]" }); - using (var b = CreateApkBuilder ("temp/BuildIncrementingAssemblyVersion")) { + using (var b = CreateApkBuilder ()) { Assert.IsTrue (b.Build (proj), "Build should have succeeded."); var acwmapPath = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, "acw-map.txt"); @@ -836,7 +850,7 @@ public void BuildIncrementingAssemblyVersion () b.Target = "Rebuild"; b.BuildLogFile = "rebuild.log"; - Assert.IsTrue (b.Build (proj), "Rebuild should have succeeded."); + Assert.IsTrue (b.Build (proj, doNotCleanupOnUpdate: true), "Rebuild should have succeeded."); var secondAssemblyVersion = AssemblyName.GetAssemblyName (assemblyPath).Version; Assert.AreNotEqual (firstAssemblyVersion, secondAssemblyVersion); @@ -920,7 +934,7 @@ public void CSharp8Features ([Values (true, false)] bool bindingProject) } [Test] - [Category ("SmokeTests")] + [Category ("SmokeTests"), Category ("MkBundle")] public void BuildMkBundleApplicationRelease () { var proj = new XamarinAndroidApplicationProject () { IsRelease = true, BundleAssemblies = true }; @@ -946,7 +960,7 @@ public void BuildMkBundleApplicationRelease () } [Test] - [Category ("Minor")] + [Category ("Minor"), Category ("MkBundle")] public void BuildMkBundleApplicationReleaseAllAbi () { var proj = new XamarinAndroidApplicationProject () { IsRelease = true, BundleAssemblies = true }; @@ -976,7 +990,7 @@ public void BuildMkBundleApplicationReleaseAllAbi () [Test] [TestCaseSource (nameof (AotChecks))] - [Category ("SmokeTests")] + [Category ("SmokeTests"), Category ("AOT")] public void BuildAotApplicationAndÜmläüts (string supportedAbis, bool enableLLVM, bool expectedResult) { var path = Path.Combine ("temp", string.Format ("BuildAotApplication AndÜmläüts_{0}_{1}_{2}", supportedAbis, enableLLVM, expectedResult)); @@ -1045,7 +1059,7 @@ public void BuildAotApplicationAndÜmläüts (string supportedAbis, bool enableL [Test] [TestCaseSource (nameof (AotChecks))] - [Category ("Minor")] + [Category ("Minor"), Category ("MkBundle"), Category ("AOT")] public void BuildAotApplicationAndBundleAndÜmläüts (string supportedAbis, bool enableLLVM, bool expectedResult) { var path = Path.Combine ("temp", string.Format ("BuildAotApplicationAndBundle AndÜmläüts_{0}_{1}_{2}", supportedAbis, enableLLVM, expectedResult)); @@ -1348,6 +1362,7 @@ public void MultiDexAndCodeShrinker ([Values ("proguard", "r8")] string linkTool proj.LinkTool = linkTool; if (linkTool == "proguard") proj.DexTool = "dx"; + AssertDexToolSupported (proj.DexTool); using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) { Assert.IsTrue (b.Build (proj), "Build should have succeeded."); @@ -2017,6 +2032,7 @@ public void CheckWhichRuntimeIsIncluded (string supportedAbi, bool debugSymbols, } [Test] + [Category ("AOT"), Category ("MonoSymbolicate")] [TestCaseSource (nameof (SequencePointChecks))] public void CheckSequencePointGeneration (bool isRelease, bool monoSymbolArchive, bool aotAssemblies, bool debugSymbols, string debugType, bool embedMdb, string expectedRuntime) @@ -2123,8 +2139,6 @@ public void BuildWithNativeLibraries ([Values (true, false)] bool isRelease) References = { new BuildItem ("ProjectReference","..\\Library1\\Library1.csproj"), new BuildItem ("ProjectReference","..\\Library2\\Library2.csproj"), - new BuildItem.Reference ("Mono.Data.Sqlite"), - new BuildItem.Reference ("Mono.Posix"), }, OtherBuildItems = { new AndroidItem.AndroidNativeLibrary ("armeabi-v7a\\libRSSupport.so") { @@ -2135,20 +2149,23 @@ public void BuildWithNativeLibraries ([Values (true, false)] bool isRelease) KnownPackages.Xamarin_Android_Support_v8_RenderScript_28_0_0_3, } }; - proj.SetProperty ("TargetFrameworkVersion", "v7.1"); proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86"); - proj.MainActivity = proj.DefaultMainActivity.Replace ("int count = 1;", @"int count = 1; + if (Builder.UseDotNet) { + proj.AddDotNetCompatPackages (); + } else { + //NOTE: Mono.Data.Sqlite and Mono.Posix do not exist in .NET 5+ + proj.References.Add (new BuildItem.Reference ("Mono.Data.Sqlite")); + proj.References.Add (new BuildItem.Reference ("Mono.Posix")); + proj.MainActivity = proj.DefaultMainActivity.Replace ("int count = 1;", @"int count = 1; Mono.Data.Sqlite.SqliteConnection connection = null; Mono.Unix.UnixFileInfo fileInfo = null;"); + } var path = Path.Combine (Root, "temp", string.Format ("BuildWithNativeLibraries_{0}", isRelease)); using (var b1 = CreateDllBuilder (Path.Combine (path, dll2.ProjectName))) { - b1.Verbosity = LoggerVerbosity.Diagnostic; Assert.IsTrue (b1.Build (dll2), "Build should have succeeded."); using (var b = CreateDllBuilder (Path.Combine (path, dll.ProjectName))) { - b.Verbosity = LoggerVerbosity.Diagnostic; Assert.IsTrue (b.Build (dll), "Build should have succeeded."); using (var builder = CreateApkBuilder (Path.Combine (path, proj.ProjectName))) { - builder.Verbosity = LoggerVerbosity.Diagnostic; Assert.IsTrue (builder.Build (proj), "Build should have succeeded."); var apk = Path.Combine (Root, builder.ProjectDirectory, proj.IntermediateOutputPath, "android", "bin", "UnnamedProject.UnnamedProject.apk"); @@ -2165,18 +2182,25 @@ public void BuildWithNativeLibraries ([Values (true, false)] bool isRelease) Assert.IsNotNull (data, "libtest1.so for armeabi-v7a should exist in the apk."); data = ZipHelper.ReadFileFromZip (zipFile, "lib/armeabi-v7a/libRSSupport.so"); Assert.IsNotNull (data, "libRSSupport.so for armeabi-v7a should exist in the apk."); - data = ZipHelper.ReadFileFromZip (zipFile, "lib/x86/libsqlite3_xamarin.so"); - Assert.IsNotNull (data, "libsqlite3_xamarin.so for x86 should exist in the apk."); - data = ZipHelper.ReadFileFromZip (zipFile, "lib/armeabi-v7a/libsqlite3_xamarin.so"); - Assert.IsNotNull (data, "libsqlite3_xamarin.so for armeabi-v7a should exist in the apk."); - data = ZipHelper.ReadFileFromZip (zipFile, "lib/x86/libMonoPosixHelper.so"); - Assert.IsNotNull (data, "libMonoPosixHelper.so for x86 should exist in the apk."); - data = ZipHelper.ReadFileFromZip (zipFile, "lib/armeabi-v7a/libMonoPosixHelper.so"); - Assert.IsNotNull (data, "libMonoPosixHelper.so for armeabi-v7a should exist in the apk."); - data = ZipHelper.ReadFileFromZip (zipFile, "lib/x86/libmono-native.so"); - Assert.IsNotNull (data, "libmono-native.so for x86 should exist in the apk."); - data = ZipHelper.ReadFileFromZip (zipFile, "lib/armeabi-v7a/libmono-native.so"); - Assert.IsNotNull (data, "libmono-native.so for armeabi-v7a should exist in the apk."); + if (Builder.UseDotNet) { + data = ZipHelper.ReadFileFromZip (zipFile, "lib/x86/libSystem.Native.so"); + Assert.IsNotNull (data, "libSystem.Native.so for x86 should exist in the apk."); + data = ZipHelper.ReadFileFromZip (zipFile, "lib/armeabi-v7a/libSystem.Native.so"); + Assert.IsNotNull (data, "libSystem.Native.so for armeabi-v7a should exist in the apk."); + } else { + data = ZipHelper.ReadFileFromZip (zipFile, "lib/x86/libmono-native.so"); + Assert.IsNotNull (data, "libmono-native.so for x86 should exist in the apk."); + data = ZipHelper.ReadFileFromZip (zipFile, "lib/armeabi-v7a/libmono-native.so"); + Assert.IsNotNull (data, "libmono-native.so for armeabi-v7a should exist in the apk."); + data = ZipHelper.ReadFileFromZip (zipFile, "lib/x86/libMonoPosixHelper.so"); + Assert.IsNotNull (data, "libMonoPosixHelper.so for x86 should exist in the apk."); + data = ZipHelper.ReadFileFromZip (zipFile, "lib/armeabi-v7a/libMonoPosixHelper.so"); + Assert.IsNotNull (data, "libMonoPosixHelper.so for armeabi-v7a should exist in the apk."); + data = ZipHelper.ReadFileFromZip (zipFile, "lib/x86/libsqlite3_xamarin.so"); + Assert.IsNotNull (data, "libsqlite3_xamarin.so for x86 should exist in the apk."); + data = ZipHelper.ReadFileFromZip (zipFile, "lib/armeabi-v7a/libsqlite3_xamarin.so"); + Assert.IsNotNull (data, "libsqlite3_xamarin.so for armeabi-v7a should exist in the apk."); + } } } } @@ -2344,6 +2368,7 @@ public void ApplicationIdPlaceholder () } [Test] + [Category ("DotNetIgnore")] // Xamarin.Build.Download needs updated $(TargetFramework) checks public void ExtraAaptManifest () { var proj = new XamarinAndroidApplicationProject (); @@ -2422,6 +2447,7 @@ public void AarContentExtraction ([Values (false, true)] bool useAapt2) } [Test] + [Category ("DotNetIgnore")] // n/a in .NET 5+ public void CheckTargetFrameworkVersion ([Values (true, false)] bool isRelease) { var proj = new XamarinAndroidApplicationProject () { @@ -2583,7 +2609,7 @@ public void BuildReleaseApplication () } [Test] - [Category ("SmokeTests"), Category ("dotnet")] + [Category ("SmokeTests"), Category ("AOT")] public void BuildApplicationWithSpacesInPath ([Values (true, false)] bool enableMultiDex, [Values ("dx", "d8")] string dexTool, [Values ("", "proguard", "r8")] string linkTool) { AssertDexToolSupported (dexTool); @@ -2676,6 +2702,7 @@ public void BuildReleaseApplicationWithNugetPackages () [Test] [NonParallelizable] + [Category ("PackagesConfig")] public void BuildWithResolveAssembliesFailure ([Values (true, false)] bool usePackageReference) { var path = Path.Combine ("temp", TestContext.CurrentContext.Test.Name); @@ -2748,22 +2775,20 @@ public void BuildAfterAddingNuget () IsRelease = true, TargetFrameworkVersion = "7.1", }; - using (var b = CreateApkBuilder (Path.Combine ("temp", TestContext.CurrentContext.Test.Name))) { + using (var b = CreateApkBuilder ()) { Assert.IsTrue (b.Build (proj), "first build should have succeeded."); string build_props = b.Output.GetIntermediaryPath ("build.props"); FileAssert.Exists (build_props, "build.props should exist after first build."); proj.PackageReferences.Add (KnownPackages.SupportV7CardView_27_0_2_1); - foreach (var reference in KnownPackages.SupportV7CardView_27_0_2_1.References) { - reference.Timestamp = DateTimeOffset.UtcNow; - proj.References.Add (reference); - } - b.Save (proj, doNotCleanupOnUpdate: true); - Assert.IsTrue (b.Build (proj), "second build should have succeeded."); + if (Builder.UseDotNet) + proj.AddDotNetCompatPackages (); + + Assert.IsTrue (b.Build (proj, doNotCleanupOnUpdate: true), "second build should have succeeded."); FileAssert.Exists (build_props, "build.props should exist after second build."); proj.MainActivity = proj.DefaultMainActivity.Replace ("clicks", "CLICKS"); proj.Touch ("MainActivity.cs"); - Assert.IsTrue (b.Build (proj), "third build should have succeeded."); + Assert.IsTrue (b.Build (proj, doNotCleanupOnUpdate: true), "third build should have succeeded."); Assert.IsTrue (b.Output.IsTargetSkipped ("_CleanIntermediateIfNeeded"), "A build with no changes to NuGets should *not* trigger `_CleanIntermediateIfNeeded`!"); FileAssert.Exists (build_props, "build.props should exist after third build."); } @@ -2771,6 +2796,7 @@ public void BuildAfterAddingNuget () //This test validates the _CleanIntermediateIfNeeded target [Test] + [Category ("DotNetIgnore")] // Xamarin.Forms version is too old, uses net45 MSBuild tasks [NonParallelizable] public void BuildAfterUpgradingNuget () { @@ -2823,6 +2849,7 @@ public void BuildAfterUpgradingNuget () } [Test] + [Category ("DotNetIgnore")] // Xamarin.Forms version is too old, uses net45 MSBuild tasks [NonParallelizable] public void CompileBeforeUpgradingNuGet () { @@ -3002,6 +3029,7 @@ public void CheckLibraryImportsUpgrade () } [Test] + [Category ("DotNetIgnore")] // n/a in .NET 5+, because it uses 'netcoreapp1.0\pclcrypto.dll' public void ResolveLibraryImportsWithInvalidZip () { var proj = new XamarinAndroidApplicationProject { @@ -3009,9 +3037,7 @@ public void ResolveLibraryImportsWithInvalidZip () KnownPackages.PCLCrypto_Alpha, }, }; - using (var b = CreateApkBuilder (Path.Combine ("temp", TestContext.CurrentContext.Test.Name))) { - b.Target = "Restore"; - Assert.IsTrue (b.Build (proj), "Restore should have succeeded."); + using (var b = CreateApkBuilder ()) { b.Target = "Build"; b.ThrowOnBuildFailure = false; if (b.Build (proj)) { @@ -3141,6 +3167,7 @@ public void AndroidLibraryProjectsZipWithOddPaths () [Test] [TestCaseSource (nameof (validateJavaVersionTestCases))] + [Category ("DotNetIgnore")] // n/a under .NET 5+ public void ValidateJavaVersion (string targetFrameworkVersion, string buildToolsVersion, string javaVersion, string latestSupportedJavaVersion, bool expectedResult) { var path = Path.Combine ("temp", $"ValidateJavaVersion_{targetFrameworkVersion}_{buildToolsVersion}_{latestSupportedJavaVersion}_{javaVersion}"); @@ -3200,6 +3227,7 @@ public void IfAndroidJarDoesNotExistThrowXA5207 () } [Test] + [Category ("DotNetIgnore")] // n/a under .NET 5+ public void ValidateUseLatestAndroid () { var apis = new ApiInfo [] { @@ -3271,7 +3299,7 @@ public void ValidateUseLatestAndroid () [Test] [NonParallelizable] - [Category ("SmokeTests")] + [Category ("SmokeTests"), Category ("AOT")] public void BuildAMassiveApp() { var testPath = Path.Combine("temp", "BuildAMassiveApp"); @@ -3406,6 +3434,7 @@ public void Dispose () } [Test] + [Category ("DotNetIgnore")] // n/a for .NET 5+ public void RunXABuildInParallel () { var xabuild = new ProjectBuilder ("temp/RunXABuildInParallel").BuildTool; @@ -3583,6 +3612,7 @@ public void MissingOrgApacheHttpClient ([Values ("dx", "d8")] string dexTool) //NOTE: tests type forwarders in Mono.Android.dll to System.Drawing.Common.dll [Test] + [Category ("DotNetIgnore")] // Fails with: error CS0433: The type 'Color' exists in both 'Splat' and 'System.Drawing.Primitives' public void SystemDrawingCommon () { var proj = new XamarinAndroidApplicationProject { @@ -3632,13 +3662,14 @@ public void MicrosoftExtensionsHttp () } [Test] + [Category ("DotNetIgnore")] // n/a on .NET 5+, does not use $(AndroidSupportedAbis) [TestCase ("armeabi;armeabi-v7a", TestName = "XA0115")] [TestCase ("armeabi,armeabi-v7a", TestName = "XA0115Commas")] public void XA0115 (string abis) { var proj = new XamarinAndroidApplicationProject (); proj.SetProperty (KnownProperties.AndroidSupportedAbis, abis); - using (var builder = CreateApkBuilder (Path.Combine ("temp", TestName))) { + using (var builder = CreateApkBuilder ()) { builder.ThrowOnBuildFailure = false; Assert.IsFalse (builder.Build (proj), "Build should have failed with XA0115."); StringAssertEx.Contains ($"error XA0115", builder.LastBuildOutput, "Error should be XA0115"); @@ -3876,7 +3907,8 @@ public class ApplicationRegistration { }"); File.WriteAllText (oldMonoPackageManagerClass, ""); File.WriteAllText (seppukuClass, ""); // Change $(XamarinAndroidVersion) to trigger _CleanIntermediateIfNeeded - Assert.IsTrue (b.Build (proj, parameters: new [] { "XamarinAndroidVersion=99.99" }, doNotCleanupOnUpdate: true), "Build should have succeeded."); + var property = Builder.UseDotNet ? "AndroidNETSdkVersion" : "XamarinAndroidVersion"; + Assert.IsTrue (b.Build (proj, parameters: new [] { $"{property}=99.99" }, doNotCleanupOnUpdate: true), "Build should have succeeded."); foreach (var target in targets) { Assert.IsFalse (b.Output.IsTargetSkipped (target), $"`{target}` should *not* be skipped."); } @@ -3976,11 +4008,20 @@ public void AllResourcesInClassLibrary ([Values (true, false)] bool useAapt2) new BuildItem.Source ("Foo.cs") { TextContent = () => "public class Foo : Bar { }" }, + }, + OtherBuildItems = { + new BuildItem ("None", "Properties\\AndroidManifest.xml") { + TextContent = () => lib.AndroidManifest, + }, } }; app.AndroidResources.Clear (); // No Resources - app.SetProperty ("AndroidResgenFile", "Resources\\Resource.designer.cs"); - app.SetProperty ("AndroidApplication", "True"); + if (Builder.UseDotNet) { + app.SetProperty (KnownProperties.OutputType, "Exe"); + } else { + app.SetProperty ("AndroidResgenFile", "Resources\\Resource.designer.cs"); + app.SetProperty ("AndroidApplication", "True"); + } app.SetProperty ("AndroidUseAapt2", useAapt2.ToString ()); app.References.Add (new BuildItem.ProjectReference ($"..\\{lib.ProjectName}\\{lib.ProjectName}.csproj", lib.ProjectName, lib.ProjectGuid)); @@ -3993,7 +4034,7 @@ public void AllResourcesInClassLibrary ([Values (true, false)] bool useAapt2) var r_txt = Path.Combine (Root, appBuilder.ProjectDirectory, app.IntermediateOutputPath, "R.txt"); FileAssert.Exists (r_txt); - var resource_designer_cs = Path.Combine (Root, appBuilder.ProjectDirectory, "Resources", "Resource.designer.cs"); + var resource_designer_cs = GetResourceDesignerPath (appBuilder, app); FileAssert.Exists (resource_designer_cs); var contents = File.ReadAllText (resource_designer_cs); Assert.AreNotEqual ("", contents); @@ -4001,6 +4042,7 @@ public void AllResourcesInClassLibrary ([Values (true, false)] bool useAapt2) } [Test] + [Category ("DotNetIgnore")] // n/a on .NET 5+, does not use $(AndroidSupportedAbis) public void AbiDelimiters ([Values ("armeabi-v7a%3bx86", "armeabi-v7a,x86")] string abis) { var proj = new XamarinAndroidApplicationProject (); @@ -4171,7 +4213,9 @@ public void XA1018 () [Test] public void XA4310 ([Values ("apk", "aab")] string packageFormat) { - var proj = new XamarinAndroidApplicationProject (); + var proj = new XamarinAndroidApplicationProject { + IsRelease = true, + }; proj.SetProperty ("AndroidKeyStore", "true"); proj.SetProperty ("AndroidSigningKeyStore", "DoesNotExist"); proj.SetProperty ("AndroidSigningStorePass", "android"); @@ -4180,17 +4224,19 @@ public void XA4310 ([Values ("apk", "aab")] string packageFormat) proj.SetProperty ("AndroidPackageFormat", packageFormat); using (var builder = CreateApkBuilder ()) { builder.ThrowOnBuildFailure = false; - builder.Target = "SignAndroidPackage"; Assert.IsFalse (builder.Build (proj), "Build should have failed with XA4310."); StringAssertEx.Contains ("error XA4310", builder.LastBuildOutput, "Error should be XA4310"); StringAssertEx.Contains ("`DoesNotExist`", builder.LastBuildOutput, "Error should include the name of the nonexistent file"); - StringAssertEx.Contains ("0 Warning(s)", builder.LastBuildOutput, "Should have no MSBuild warnings."); - + if (!Builder.UseDotNet) { + // ILLink produces lots of warnings in .NET 5+ + StringAssertEx.Contains ("0 Warning(s)", builder.LastBuildOutput, "Should have no MSBuild warnings."); + } } } [Test] + [Category ("AOT")] public void HybridAOT () { var proj = new XamarinAndroidApplicationProject () { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/CodeBehindTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/CodeBehindTests.cs index 648b8cbb65c..560fa231047 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/CodeBehindTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/CodeBehindTests.cs @@ -13,6 +13,7 @@ namespace Xamarin.Android.Build.Tests { [Category ("Node-2")] + [Category ("StaticProject")] // TODO: enable for .NET 5 [Parallelizable (ParallelScope.Children)] public class CodeBehindTests { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/EmbeddedDSOTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/EmbeddedDSOTests.cs index d67b2e7fc74..e594309e2de 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/EmbeddedDSOTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/EmbeddedDSOTests.cs @@ -18,6 +18,7 @@ namespace Xamarin.Android.Build.Tests { [Category ("Node-2")] + [Category ("StaticProject")] // TODO: enable for .NET 5 [Parallelizable (ParallelScope.Children)] public class EmbeddedDSOTests : BaseTest { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/EnvironmentContentTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/EnvironmentContentTests.cs index a230e8d18db..f66c1031e1a 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/EnvironmentContentTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/EnvironmentContentTests.cs @@ -142,6 +142,7 @@ public void CheckConcurrentGC () } [Test] + [Category ("MonoSymbolicate")] public void CheckBuildIdIsUnique ([Values ("apk", "aab")] string packageFormat) { const string supportedAbis = "armeabi-v7a;x86"; @@ -234,6 +235,7 @@ public void CheckHttpClientHandlerType () }; [Test] + [Category ("DotNetIgnore")] // .NET 5+ does not use these native libraries [TestCaseSource (nameof (TlsProviderTestCases))] public void BuildWithTlsProvider (string androidTlsProvider, bool isRelease, bool expected) { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/IncrementalBuildTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/IncrementalBuildTest.cs index 4856132d292..a268033f026 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/IncrementalBuildTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/IncrementalBuildTest.cs @@ -179,11 +179,13 @@ public void AllProjectsHaveSameOutputDirectory() var app1 = new XamarinAndroidApplicationProject () { ProjectName = "App1", + PackageName = "com.companyname.App1", OutputPath = Path.Combine("..","bin","Debug"), }; sb.Projects.Add (app1); var app2 = new XamarinAndroidApplicationProject () { ProjectName = "App2", + PackageName = "com.companyname.App2", OutputPath = Path.Combine("..","bin","Debug"), }; sb.Projects.Add (app2); @@ -886,6 +888,7 @@ void AssertAssemblyFilesInFileWrites (XamarinAndroidApplicationProject proj, Pro #pragma warning restore 414 [Test] + [Category ("AOT")] [TestCaseSource (nameof (AotChecks))] public void BuildIncrementalAot (string supportedAbis, string androidAotMode, bool aotAssemblies, bool expectedResult) { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/MSBuildSdkExtrasTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/MSBuildSdkExtrasTests.cs index d607414ff05..98fb1f2218e 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/MSBuildSdkExtrasTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/MSBuildSdkExtrasTests.cs @@ -8,7 +8,7 @@ namespace Xamarin.Android.Build.Tests { [TestFixture] [NonParallelizable] // On MacOS, parallel /restore causes issues - [Category ("Node-3")] + [Category ("Node-3"), Category ("DotNetIgnore")] // Uses MSBuild.Sdk.Extras public class MSBuildSdkExtrasTests : BaseTest { [Test] diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/MakeBundleTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/MakeBundleTests.cs index f40f87e86ab..d1ba7174664 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/MakeBundleTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/MakeBundleTests.cs @@ -16,7 +16,7 @@ namespace Xamarin.Android.Build.Tests { - [Category ("Node-2")] + [Category ("Node-2"), Category ("MkBundle"), Category ("StaticProject")] [Parallelizable (ParallelScope.Children)] public class MakeBundleTests { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/ManifestTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/ManifestTest.cs index 3316449a8ad..84ebe3a5306 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/ManifestTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/ManifestTest.cs @@ -585,6 +585,7 @@ public void ModifyManifest ([Values (true, false)] bool isRelease) } [Test] + [Category ("LibraryProjectZip")] public void MergeLibraryManifest () { byte [] classesJar; diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs index 70bed86c32d..62842bf86ba 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs @@ -27,6 +27,7 @@ public class PackagingTest : BaseTest #pragma warning restore 414 [Test] + [Category ("MonoSymbolicate")] [TestCaseSource (nameof(ManagedSymbolsArchiveSource))] public void CheckManagedSymbolsArchive (bool isRelease, bool monoSymbolArchive, string packageFormat) { @@ -51,42 +52,61 @@ public void CheckManagedSymbolsArchive (bool isRelease, bool monoSymbolArchive, [Test] public void CheckIncludedAssemblies () { - var proj = new XamarinAndroidApplicationProject () { - IsRelease = true, - PackageReferences = { - new Package () { - Id = "System.Runtime.InteropServices.WindowsRuntime", - Version = "4.0.1", - TargetFramework = "monoandroid71", - }, - }, - }; - proj.References.Add (new BuildItem.Reference ("Mono.Data.Sqlite.dll")); - var expectedFiles = new string [] { - "Java.Interop.dll", - "Mono.Android.dll", - "mscorlib.dll", - "System.Collections.Concurrent.dll", - "System.Collections.dll", - "System.Core.dll", - "System.Diagnostics.Debug.dll", - "System.dll", - "System.Linq.dll", - "System.Reflection.dll", - "System.Reflection.Extensions.dll", - "System.Runtime.dll", - "System.Runtime.Extensions.dll", - "System.Runtime.InteropServices.dll", - "System.Runtime.Serialization.dll", - "System.Threading.dll", - "UnnamedProject.dll", - "Mono.Data.Sqlite.dll", - "Mono.Data.Sqlite.dll.config", + var proj = new XamarinAndroidApplicationProject { + IsRelease = true }; - using (var b = CreateApkBuilder (Path.Combine ("temp", TestContext.CurrentContext.Test.Name))) { - b.Verbosity = Microsoft.Build.Framework.LoggerVerbosity.Diagnostic; - b.ThrowOnBuildFailure = false; - Assert.IsTrue (b.Build (proj), "build failed"); + proj.SetAndroidSupportedAbis ("armeabi-v7a"); + if (!Builder.UseDotNet) { + proj.PackageReferences.Add (new Package { + Id = "System.Runtime.InteropServices.WindowsRuntime", + Version = "4.0.1", + TargetFramework = "monoandroid71", + }); + proj.References.Add (new BuildItem.Reference ("Mono.Data.Sqlite.dll")); + } + var expectedFiles = Builder.UseDotNet ? + new [] { + "Java.Interop.dll", + "Mono.Android.dll", + "System.ComponentModel.Primitives.dll", + "System.Console.dll", + "System.Linq.Expressions.dll", + "System.ObjectModel.dll", + "System.Private.Xml.dll", + "System.Runtime.CompilerServices.Unsafe.dll", + "System.Runtime.Serialization.Formatters.dll", + "System.Runtime.Serialization.Primitives.dll", + "System.Security.Cryptography.Algorithms.dll", + "System.Security.Cryptography.Primitives.dll", + "System.Private.CoreLib.dll", + "System.Collections.Concurrent.dll", + "System.Collections.dll", + "System.Linq.dll", + "UnnamedProject.dll", + } : + new [] { + "Java.Interop.dll", + "Mono.Android.dll", + "mscorlib.dll", + "System.Collections.Concurrent.dll", + "System.Collections.dll", + "System.Core.dll", + "System.Diagnostics.Debug.dll", + "System.dll", + "System.Linq.dll", + "System.Reflection.dll", + "System.Reflection.Extensions.dll", + "System.Runtime.dll", + "System.Runtime.Extensions.dll", + "System.Runtime.InteropServices.dll", + "System.Runtime.Serialization.dll", + "System.Threading.dll", + "UnnamedProject.dll", + "Mono.Data.Sqlite.dll", + "Mono.Data.Sqlite.dll.config", + }; + using (var b = CreateApkBuilder ()) { + Assert.IsTrue (b.Build (proj), "build should have succeeded."); var apk = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, "android", "bin", "UnnamedProject.UnnamedProject.apk"); using (var zip = ZipHelper.OpenZip (apk)) { @@ -319,16 +339,19 @@ public void CheckSignApk ([Values(true, false)] bool useApkSigner, [Values(true, proj.SetProperty (proj.ReleaseProperties, "AndroidKeyStore", "True"); proj.SetProperty (proj.ReleaseProperties, "AndroidSigningKeyStore", keyfile); proj.SetProperty (proj.ReleaseProperties, "AndroidSigningKeyAlias", "releasestore"); - proj.SetProperty (proj.ReleaseProperties, "AndroidSigningKeyPass", pass); - proj.SetProperty (proj.ReleaseProperties, "AndroidSigningStorePass", pass); + proj.SetProperty (proj.ReleaseProperties, "AndroidSigningKeyPass", Uri.EscapeDataString (pass)); + proj.SetProperty (proj.ReleaseProperties, "AndroidSigningStorePass", Uri.EscapeDataString (pass)); proj.SetProperty (proj.ReleaseProperties, KnownProperties.AndroidCreatePackagePerAbi, perAbiApk); proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86"); using (var b = CreateApkBuilder (Path.Combine ("temp", TestContext.CurrentContext.Test.Name))) { var bin = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath); Assert.IsTrue (b.Build (proj), "First build failed"); - Assert.IsTrue (StringAssertEx.ContainsText (b.LastBuildOutput, " 0 Warning(s)"), - "First build should not contain warnings! Contains\n" + - string.Join ("\n", b.LastBuildOutput.Where (line => line.Contains ("warning")))); + if (!Builder.UseDotNet) { + // In .NET 5+, there are ILLink warnings + Assert.IsTrue (StringAssertEx.ContainsText (b.LastBuildOutput, " 0 Warning(s)"), + "First build should not contain warnings! Contains\n" + + string.Join ("\n", b.LastBuildOutput.Where (line => line.Contains ("warning")))); + } //Make sure the APKs are signed foreach (var apk in Directory.GetFiles (bin, "*-Signed.apk")) { @@ -341,9 +364,12 @@ public void CheckSignApk ([Values(true, false)] bool useApkSigner, [Values(true, item.TextContent = () => proj.StringsXml.Replace ("${PROJECT_NAME}", "Foo"); item.Timestamp = null; Assert.IsTrue (b.Build (proj), "Second build failed"); - Assert.IsTrue (StringAssertEx.ContainsText (b.LastBuildOutput, " 0 Warning(s)"), + if (!Builder.UseDotNet) { + // In .NET 5+, there are ILLink warnings + Assert.IsTrue (StringAssertEx.ContainsText (b.LastBuildOutput, " 0 Warning(s)"), "Second build should not contain warnings! Contains\n" + string.Join ("\n", b.LastBuildOutput.Where (line => line.Contains ("warning")))); + } //Make sure the APKs are signed foreach (var apk in Directory.GetFiles (bin, "*-Signed.apk")) { @@ -355,6 +381,7 @@ public void CheckSignApk ([Values(true, false)] bool useApkSigner, [Values(true, } [Test] + [Category ("DotNetIgnore")] // Xamarin.Forms version is too old, uses net45 MSBuild tasks [NonParallelizable] // Commonly fails NuGet restore public void CheckAapt2WarningsDoNotGenerateErrors () { @@ -422,7 +449,7 @@ public void CheckAppBundle ([Values (true, false)] bool isRelease) } [Test] - [Category ("SmokeTests")] + [Category ("SmokeTests"), Category ("DotNetIgnore")] // Xamarin.Forms version is too old, uses net45 MSBuild tasks public void NetStandardReferenceTest () { var netStandardProject = new DotNetStandard () { @@ -635,6 +662,7 @@ protected override void OnCreate (Bundle bundle) } [Test] + [Category ("DotNetIgnore")] // Uses MSBuild.Sdk.Extras public void CheckTheCorrectRuntimeAssemblyIsUsedFromNuget () { string monoandroidFramework = "monoandroid10.0"; @@ -723,6 +751,7 @@ public void MissingDexFile () var proj = new XamarinAndroidApplicationProject { DexTool = "dx" }; + AssertDexToolSupported (proj.DexTool); using (var b = CreateApkBuilder ()) { Assert.IsTrue (b.Build (proj, parameters: parameters), "Build should have succeeded."); var apk = Path.Combine (Root, b.ProjectDirectory, diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/LinkerTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/LinkerTests.cs index 683336d2c0a..0ee9968fc1a 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/LinkerTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/LinkerTests.cs @@ -169,6 +169,7 @@ private void PreserveCustomHttpClientHandler (string handlerType, string handler } [Test] + [Category ("DotNetIgnore")] // HttpClientHandler options not implemented in .NET 5+ yet public void PreserveCustomHttpClientHandlers () { PreserveCustomHttpClientHandler ("Xamarin.Android.Net.AndroidClientHandler", "", @@ -178,24 +179,12 @@ public void PreserveCustomHttpClientHandlers () } [Test] - public void WarnAboutAppDomainsRelease () - { - var proj = new XamarinAndroidApplicationProject () { IsRelease = true }; - WarnAboutAppDomains (proj, TestName); - } - - [Test] - public void WarnAboutAppDomainsDebug () - { - var proj = new XamarinAndroidApplicationProject (); - WarnAboutAppDomains (proj, TestName); - } - - void WarnAboutAppDomains (XamarinAndroidApplicationProject proj, string testName) + [Category ("DotNetIgnore")] // n/a on .NET 5+ + public void WarnAboutAppDomains ([Values (true, false)] bool isRelease) { + var proj = new XamarinAndroidApplicationProject () { IsRelease = isRelease }; proj.MainActivity = proj.DefaultMainActivity.Replace ("base.OnCreate (bundle);", "base.OnCreate (bundle);\nvar appDomain = System.AppDomain.CreateDomain (\"myDomain\");"); - var projDirectory = Path.Combine ("temp", testName); - using (var b = CreateApkBuilder (projDirectory)) { + using (var b = CreateApkBuilder ()) { Assert.IsTrue (b.Build (proj), "Build should have succeeded."); Assert.IsTrue (StringAssertEx.ContainsText (b.LastBuildOutput, "2 Warning(s)"), "MSBuild should count 2 warnings."); Assert.IsTrue (StringAssertEx.ContainsText (b.LastBuildOutput, "warning CS0618: 'AppDomain.CreateDomain(string)' is obsolete: 'AppDomain.CreateDomain will no longer be supported in .NET 5 and later."), "Should warn CS0618 about creating AppDomain."); @@ -206,6 +195,7 @@ void WarnAboutAppDomains (XamarinAndroidApplicationProject proj, string testName [Test] public void LinkDescription () { + string assembly_name = Builder.UseDotNet ? "System.Console" : "mscorlib"; string linker_xml = ""; var proj = new XamarinAndroidApplicationProject { @@ -223,8 +213,8 @@ public void LinkDescription () Assert.IsTrue (b.Build (proj), "first build should have succeeded."); linker_xml = -@" - +$@" + @@ -237,8 +227,8 @@ public void LinkDescription () var apk = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath, $"{proj.PackageName}.apk"); FileAssert.Exists (apk); using (var zip = ZipHelper.OpenZip (apk)) { - var entry = zip.ReadEntry ("assemblies/mscorlib.dll"); - Assert.IsNotNull (entry, "mscorlib.dll should exist in apk!"); + var entry = zip.ReadEntry ($"assemblies/{assembly_name}.dll"); + Assert.IsNotNull (entry, $"{assembly_name}.dll should exist in apk!"); using (var stream = new MemoryStream ()) { entry.Extract (stream); stream.Position = 0; diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/BaseTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/BaseTest.cs index c40d480aeac..79c6ef89f34 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/BaseTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/BaseTest.cs @@ -467,6 +467,17 @@ protected string GetPathToAapt () return GetPathToLatestBuildTools (exe); } + protected string GetResourceDesignerPath (ProjectBuilder builder, XamarinAndroidProject project) + { + string path; + if (Builder.UseDotNet) { + path = Path.Combine (Root, builder.ProjectDirectory, project.IntermediateOutputPath); + } else { + path = Path.Combine (Root, builder.ProjectDirectory, "Resources"); + } + return Path.Combine (path, "Resource.designer" + project.Language.DefaultDesignerExtension); + } + [SetUp] public void TestSetup () { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/XASdkTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/XASdkTests.cs index be8a0206e13..f2d4747b6e6 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/XASdkTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/XASdkTests.cs @@ -12,7 +12,7 @@ namespace Xamarin.Android.Build.Tests { [TestFixture] [NonParallelizable] // On MacOS, parallel /restore causes issues - [Category ("Node-2")] + [Category ("Node-2"), Category ("DotNetIgnore")] // These don't need to run under `--params dotnet=true` public class XASdkTests : BaseTest { [Test] diff --git a/tests/MSBuildDeviceIntegration/Tests/XASdkDeployTests.cs b/tests/MSBuildDeviceIntegration/Tests/XASdkDeployTests.cs index 42e9ca7c865..b2fdaa3c766 100644 --- a/tests/MSBuildDeviceIntegration/Tests/XASdkDeployTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/XASdkDeployTests.cs @@ -13,7 +13,7 @@ namespace Xamarin.Android.Build.Tests { [NonParallelizable] - [Category ("UsesDevices")] + [Category ("UsesDevices"), Category ("DotNetIgnore")] // These don't need to run under `--params dotnet=true` public class XASdkDeployTests : DeviceTest { [Test]