From 7676bbfcd81bb0467e161e0227deb2d8160f96f5 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Mon, 15 Jun 2020 10:34:26 -0500 Subject: [PATCH] [build] enable all One .NET MSBuild tests This is WIP, but this will enable all tests except for the `dotnet-ignore`, `AOT`, `mkbundle`, and `mono-symbolicate` categories. I'll see what the failures look like before deciding the final categories here. --- build-tools/automation/azure-pipelines.yaml | 8 ++++ .../yaml-templates/run-msbuild-mac-tests.yaml | 4 +- .../yaml-templates/run-msbuild-win-tests.yaml | 4 +- .../targets/Microsoft.Android.Sdk.props | 3 -- .../targets/Microsoft.Android.Sdk.targets | 1 + .../Xamarin.Android.Build.Tests/BuildTest.cs | 48 +++++++++++-------- .../EnvironmentContentTests.cs | 16 ++++--- .../IncrementalBuildTest.cs | 7 ++- .../MSBuildSdkExtrasTests.cs | 2 +- .../ManifestTest.cs | 4 +- .../PackagingTest.cs | 11 +++-- .../Tasks/BundleToolTests.cs | 3 +- .../Tasks/LinkerTests.cs | 2 + .../Xamarin.Android.Build.Tests/XASdkTests.cs | 1 + .../XamarinAndroidApplicationProject.cs | 18 +++++++ .../Utilities/ProjectExtensions.cs | 19 +++++++- .../Tests/AotProfileTests.cs | 2 +- .../Tests/BugzillaTests.cs | 2 +- .../Tests/DebuggingTest.cs | 12 ++--- .../Tests/DeploymentTest.cs | 2 +- .../Tests/InstallTests.cs | 24 ++++------ .../Tests/MonoAndroidExportTest.cs | 3 +- .../Tests/XASdkDeployTests.cs | 1 + 23 files changed, 123 insertions(+), 74 deletions(-) diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml index 220b1be1fd2..b85f84b2a54 100644 --- a/build-tools/automation/azure-pipelines.yaml +++ b/build-tools/automation/azure-pipelines.yaml @@ -799,6 +799,10 @@ stages: parameters: node_id: 3 + - template: yaml-templates\run-msbuild-mac-tests.yaml + parameters: + node_id: 4 + # Xamarin.Android (Test MSBuild - Windows) - template: yaml-templates\run-msbuild-win-tests.yaml parameters: @@ -812,6 +816,10 @@ stages: parameters: node_id: 3 + - template: yaml-templates\run-msbuild-win-tests.yaml + parameters: + node_id: 4 + # Check - "Xamarin.Android (Test MSBuild With Emulator - macOS)" - job: mac_msbuilddevice_tests displayName: MSBuild With Emulator - macOS 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 d104d7c39f2..3827b6fa607 100644 --- a/build-tools/automation/yaml-templates/run-msbuild-mac-tests.yaml +++ b/build-tools/automation/yaml-templates/run-msbuild-mac-tests.yaml @@ -64,11 +64,13 @@ jobs: nunitConsoleExtraArgs: --where "cat != Node-1 && cat != Node-2 && cat != Node-3" testResultsFile: TestResult-MSBuildTests-macOS-NoNode-$(XA.Build.Configuration).xml + # Only run these tests on node 4 + - ${{ if eq(parameters.node_id, 4) }}: - 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 + nunitConsoleExtraArgs: --where "cat != dotnet-ignore && cat != AOT && cat != mkbundle && cat != mono-symbolicate" --params dotnet=true testResultsFile: TestResult-MSBuildTests-macOS-dotnet-$(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 795b9580364..9d77b3f7266 100644 --- a/build-tools/automation/yaml-templates/run-msbuild-win-tests.yaml +++ b/build-tools/automation/yaml-templates/run-msbuild-win-tests.yaml @@ -57,11 +57,13 @@ jobs: 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 + # Only run these tests on node 4 + - ${{ if eq(parameters.node_id, 4) }}: - 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 + nunitConsoleExtraArgs: --workers=4 --where "cat != dotnet-ignore && cat != AOT && cat != mkbundle && cat != mono-symbolicate" --params dotnet=true testResultsFile: TestResult-MSBuildTests-Windows-dotnet-$(XA.Build.Configuration).xml - template: upload-results.yaml diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.props b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.props index aa07e445fe0..e2c8b8ae83f 100644 --- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.props +++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.props @@ -42,9 +42,6 @@ SdkOnly true - - true - diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.targets index cb419a447df..8f7055fbccf 100644 --- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.targets +++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.targets @@ -15,6 +15,7 @@ Properties\AndroidManifest.xml Library + true 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 36f32d93370..2a97d1853d8 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 @@ -36,7 +36,7 @@ public void BuildBasicApplication ([Values (true, false)] bool isRelease) } [Test] - [Category ("SmokeTests")] + [Category ("SmokeTests"), Category ("AOT")] public void BuildBasicApplicationReleaseProfiledAot () { var proj = new XamarinAndroidApplicationProject () { @@ -51,7 +51,7 @@ public void BuildBasicApplicationReleaseProfiledAot () } } - [Test] + [Test, Category ("AOT")] public void BuildBasicApplicationReleaseProfiledAotWithoutDefaultProfile () { var proj = new XamarinAndroidApplicationProject () { @@ -904,7 +904,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 }; @@ -930,11 +930,11 @@ public void BuildMkBundleApplicationRelease () } [Test] - [Category ("Minor")] + [Category ("Minor"), Category ("mkbundle")] public void BuildMkBundleApplicationReleaseAllAbi () { var proj = new XamarinAndroidApplicationProject () { IsRelease = true, BundleAssemblies = true }; - proj.SetProperty (KnownProperties.AndroidSupportedAbis, "armeabi-v7a;x86"); + proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86"); using (var b = CreateApkBuilder ("temp/BuildMkBundleApplicationReleaseAllAbi", false)) { Assert.IsTrue (b.Build (proj), "Build should have succeeded."); foreach (var abi in new string [] { "armeabi-v7a", "x86" }) { @@ -960,7 +960,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)); @@ -970,7 +970,7 @@ public void BuildAotApplicationAndÜmläüts (string supportedAbis, bool enableL AotAssemblies = true, }; proj.SetProperty (KnownProperties.TargetFrameworkVersion, "v5.1"); - proj.SetProperty (KnownProperties.AndroidSupportedAbis, supportedAbis); + proj.SetAndroidSupportedAbis (supportedAbis); proj.SetProperty ("EnableLLVM", enableLLVM.ToString ()); bool checkMinLlvmPath = enableLLVM && (supportedAbis == "armeabi-v7a" || supportedAbis == "x86"); if (checkMinLlvmPath) { @@ -1029,7 +1029,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)); @@ -1039,7 +1039,7 @@ public void BuildAotApplicationAndBundleAndÜmläüts (string supportedAbis, boo AotAssemblies = true, }; proj.SetProperty (KnownProperties.TargetFrameworkVersion, "v5.1"); - proj.SetProperty (KnownProperties.AndroidSupportedAbis, supportedAbis); + proj.SetAndroidSupportedAbis (supportedAbis); proj.SetProperty ("EnableLLVM", enableLLVM.ToString ()); using (var b = CreateApkBuilder (path)) { if (!b.CrossCompilerAvailable (supportedAbis)) @@ -1117,7 +1117,7 @@ public void BuildProguardEnabledProject ([Values (true, false)] bool isRelease, var classes = new [] { "Lmono/MonoRuntimeProvider;", "Landroid/runtime/JavaProxyThrowable;", - "Landroid/support/v7/widget/Toolbar;" + Builder.UseDotNet ? "Landroidx/appcompat/widget/Toolbar;" : "Landroid/support/v7/widget/Toolbar;" }; foreach (var className in classes) { Assert.IsTrue (DexUtils.ContainsClassWithMethod (className, "", "()V", dexFile, AndroidSdkPath), $"`{dexFile}` should include `{className}`!"); @@ -1176,7 +1176,7 @@ public void BuildMultiDexApplication ([Values ("dx", "d8")] string dexTool) proj.UseLatestPlatformSdk = false; proj.DexTool = dexTool; proj.SetProperty ("AndroidEnableMultiDex", "True"); - if (IsWindows) { + if (IsWindows && !Builder.UseDotNet) { proj.SetProperty ("AppendTargetFrameworkToIntermediateOutputPath", "True"); } @@ -1184,7 +1184,7 @@ public void BuildMultiDexApplication ([Values ("dx", "d8")] string dexTool) proj.TargetFrameworkVersion = b.LatestTargetFrameworkVersion (); string intermediateDir; - if (IsWindows) { + if (IsWindows && !Builder.UseDotNet) { intermediateDir = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, proj.TargetFrameworkAbbreviated); } else { intermediateDir = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath); @@ -1195,7 +1195,8 @@ public void BuildMultiDexApplication ([Values ("dx", "d8")] string dexTool) var multidexKeepPath = Path.Combine (Root, b.ProjectDirectory, intermediateDir, "multidex.keep"); Assert.IsTrue (File.Exists (multidexKeepPath), "multidex.keep exists"); Assert.IsTrue (File.ReadAllLines (multidexKeepPath).Length > 1, "multidex.keep must contain more than one line."); - Assert.IsTrue (b.LastBuildOutput.ContainsText (Path.Combine (proj.TargetFrameworkVersion, "mono.android.jar")), proj.TargetFrameworkVersion + "/mono.android.jar should be used."); + if (!Builder.UseDotNet) + Assert.IsTrue (b.LastBuildOutput.ContainsText (Path.Combine (proj.TargetFrameworkVersion, "mono.android.jar")), proj.TargetFrameworkVersion + "/mono.android.jar should be used."); Assert.IsFalse (b.LastBuildOutput.ContainsText ("Duplicate zip entry"), "Should not get warning about [META-INF/MANIFEST.MF]"); } } @@ -1996,6 +1997,7 @@ public void CheckWhichRuntimeIsIncluded (string supportedAbi, bool debugSymbols, } [Test] + [Category ("AOT"), Category ("mono-symbolicate")] [TestCaseSource (nameof (SequencePointChecks))] public void CheckSequencePointGeneration (bool isRelease, bool monoSymbolArchive, bool aotAssemblies, bool debugSymbols, string debugType, bool embedMdb, string expectedRuntime) @@ -2004,8 +2006,8 @@ public void CheckSequencePointGeneration (bool isRelease, bool monoSymbolArchive IsRelease = isRelease, AotAssemblies = aotAssemblies }; - var abis = new string [] { "armeabi-v7a", "x86" }; - proj.SetProperty (KnownProperties.AndroidSupportedAbis, string.Join (";", abis)); + var abis = new [] { "armeabi-v7a", "x86" }; + proj.SetAndroidSupportedAbis (abis); proj.SetProperty (proj.ActiveConfigurationProperties, "MonoSymbolArchive", monoSymbolArchive); proj.SetProperty (proj.ActiveConfigurationProperties, "DebugSymbols", debugSymbols); proj.SetProperty (proj.ActiveConfigurationProperties, "DebugType", debugType); @@ -2115,7 +2117,7 @@ public void BuildWithNativeLibraries ([Values (true, false)] bool isRelease) } }; proj.SetProperty ("TargetFrameworkVersion", "v7.1"); - proj.SetProperty (KnownProperties.AndroidSupportedAbis, "armeabi-v7a;x86"); + proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86"); proj.MainActivity = proj.DefaultMainActivity.Replace ("int count = 1;", @"int count = 1; Mono.Data.Sqlite.SqliteConnection connection = null; Mono.Unix.UnixFileInfo fileInfo = null;"); @@ -2173,7 +2175,7 @@ public void BuildWithNativeLibraryUnknownAbi () }, } }; - proj.SetProperty (KnownProperties.AndroidSupportedAbis, "armeabi-v7a;x86"); + proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86"); using (var builder = CreateApkBuilder (Path.Combine ("temp", TestContext.CurrentContext.Test.Name))) { builder.ThrowOnBuildFailure = false; @@ -2562,7 +2564,7 @@ public void BuildReleaseApplication () } [Test] - [Category ("SmokeTests")] + [Category ("SmokeTests"), Category ("AOT")] public void BuildApplicationWithSpacesInPath ([Values (true, false)] bool enableMultiDex, [Values ("dx", "d8")] string dexTool, [Values ("", "proguard", "r8")] string linkTool) { var folderName = $"BuildReleaseApp AndÜmläüts({enableMultiDex}{dexTool}{linkTool})"; @@ -3212,6 +3214,7 @@ public void IfAndroidJarDoesNotExistThrowXA5207 () } [Test] + [Category ("AOT"), Category ("mkbundle")] [TestCase ("AotAssemblies", false)] [TestCase ("AndroidEnableProfiledAot", false)] [TestCase ("EnableLLVM", true)] @@ -3383,7 +3386,7 @@ public void ValidateUseLatestAndroid () [Test] [NonParallelizable] - [Category ("SmokeTests")] + [Category ("SmokeTests"), Category ("AOT")] public void BuildAMassiveApp() { var testPath = Path.Combine("temp", "BuildAMassiveApp"); @@ -3740,13 +3743,14 @@ public void MicrosoftExtensionsHttp () } [Test] + [Category ("dotnet-ignore")] [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"); @@ -4105,6 +4109,7 @@ public void AllResourcesInClassLibrary ([Values (true, false)] bool useAapt2) } [Test] + [Category ("dotnet-ignore")] public void AbiDelimiters ([Values ("armeabi-v7a%3bx86", "armeabi-v7a,x86")] string abis) { var proj = new XamarinAndroidApplicationProject (); @@ -4211,7 +4216,7 @@ public void PackageNamingPolicy ([Values ("LowercaseMD5", "LowercaseCrc64")] str { var proj = new XamarinAndroidApplicationProject (); proj.SetProperty ("AndroidPackageNamingPolicy", packageNamingPolicy); - proj.SetProperty (KnownProperties.AndroidSupportedAbis, "armeabi-v7a;x86"); + proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86"); using (var b = CreateApkBuilder ()) { Assert.IsTrue (b.Build (proj), "build should have succeeded."); var environment = b.Output.GetIntermediaryPath (Path.Combine ("__environment__.txt")); @@ -4293,6 +4298,7 @@ public void XA4310 ([Values ("apk", "aab")] string packageFormat) } [Test] + [Category ("AOT")] public void HybridAOT () { var proj = new XamarinAndroidApplicationProject () { 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 e93595f28a6..048e9ea8343 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 @@ -36,10 +36,10 @@ public void BuildApplicationWithMonoEnvironment ([Values ("", "Normal", "Offline }, }; //LinkSkip one assembly that contains __AndroidLibraryProjects__.zip - string linkSkip = KnownPackages.SupportV7AppCompat_27_0_2_1.Id; + string linkSkip = "FormsViewGroup"; app.SetProperty ("AndroidLinkSkip", linkSkip); app.SetProperty ("_AndroidSequencePointsMode", sequencePointsMode); - app.SetProperty (app.ReleaseProperties, KnownProperties.AndroidSupportedAbis, supportedAbis); + app.SetAndroidSupportedAbis (supportedAbis); using (var libb = CreateDllBuilder (Path.Combine ("temp", TestName, lib.ProjectName))) using (var appb = CreateApkBuilder (Path.Combine ("temp", TestName, app.ProjectName))) { Assert.IsTrue (libb.Build (lib), "Library build should have succeeded."); @@ -85,7 +85,7 @@ public void CheckMonoDebugIsAddedToEnvironment ([Values ("", "Normal", "Offline" IsRelease = true, }; proj.SetProperty ("_AndroidSequencePointsMode", sequencePointsMode); - proj.SetProperty (proj.ReleaseProperties, KnownProperties.AndroidSupportedAbis, supportedAbis); + proj.SetAndroidSupportedAbis (supportedAbis); using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) { b.Verbosity = LoggerVerbosity.Diagnostic; Assert.IsTrue (b.Build (proj), "Build should have succeeded."); @@ -118,7 +118,7 @@ public void CheckConcurrentGC () var expectedDefaultValue = "major=marksweep"; var expectedUpdatedValue = "major=marksweep-conc"; var supportedAbis = "armeabi-v7a;arm64-v8a"; - proj.SetProperty (KnownProperties.AndroidSupportedAbis, supportedAbis); + proj.SetAndroidSupportedAbis (supportedAbis); using (var b = CreateDllBuilder (Path.Combine ("temp", TestName))) { Assert.IsTrue (b.Build (proj), "Build should have succeeded."); @@ -139,6 +139,7 @@ public void CheckConcurrentGC () } [Test] + [Category ("mono-symbolicate")] public void CheckBuildIdIsUnique ([Values ("apk", "aab")] string packageFormat) { const string supportedAbis = "armeabi-v7a;x86"; @@ -151,8 +152,8 @@ public void CheckBuildIdIsUnique ([Values ("apk", "aab")] string packageFormat) proj.SetProperty (proj.ReleaseProperties, "DebugSymbols", "true"); proj.SetProperty (proj.ReleaseProperties, "DebugType", "PdbOnly"); proj.SetProperty (proj.ReleaseProperties, KnownProperties.AndroidCreatePackagePerAbi, "true"); - proj.SetProperty (proj.ReleaseProperties, KnownProperties.AndroidSupportedAbis, supportedAbis); proj.SetProperty (proj.ReleaseProperties, "AndroidPackageFormat", packageFormat); + proj.SetAndroidSupportedAbis (supportedAbis); using (var b = CreateApkBuilder ()) { b.Verbosity = Microsoft.Build.Framework.LoggerVerbosity.Diagnostic; b.ThrowOnBuildFailure = false; @@ -200,7 +201,7 @@ public void CheckHttpClientHandlerType () var expectedDefaultValue = "System.Net.Http.HttpClientHandler, System.Net.Http"; var expectedUpdatedValue = "Xamarin.Android.Net.AndroidClientHandler"; var supportedAbis = "armeabi-v7a;arm64-v8a"; - proj.SetProperty (KnownProperties.AndroidSupportedAbis, supportedAbis); + proj.SetAndroidSupportedAbis (supportedAbis); using (var b = CreateDllBuilder (Path.Combine ("temp", TestName))) { Assert.IsTrue (b.Build (proj), "Build should have succeeded."); @@ -229,6 +230,7 @@ public void CheckHttpClientHandlerType () }; [Test] + [Category ("dotnet-ignore")] // .NET 5+ does not use these native libraries [TestCaseSource (nameof (TlsProviderTestCases))] public void BuildWithTlsProvider (string androidTlsProvider, bool isRelease, bool expected) { @@ -236,7 +238,7 @@ public void BuildWithTlsProvider (string androidTlsProvider, bool isRelease, boo IsRelease = isRelease, }; var supportedAbis = new string [] { "armeabi-v7a", "arm64-v8a" }; - proj.SetProperty (KnownProperties.AndroidSupportedAbis, string.Join (";", supportedAbis)); + proj.SetAndroidSupportedAbis (supportedAbis); using (var b = CreateApkBuilder (Path.Combine ("temp", $"BuildWithTlsProvider_{androidTlsProvider}_{isRelease}_{expected}"))) { proj.SetProperty ("AndroidTlsProvider", androidTlsProvider); 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 22fea1fe8fd..21959fd4ee3 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 @@ -883,6 +883,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) { @@ -1167,11 +1168,13 @@ public void AndroidXMigrationBug () public void ChangeSupportedAbis () { var proj = new XamarinFormsAndroidApplicationProject (); - proj.SetProperty (KnownProperties.AndroidSupportedAbis, "armeabi-v7a"); + proj.SetAndroidSupportedAbis ("armeabi-v7a"); using (var b = CreateApkBuilder ()) { b.Build (proj); - var parameters = new [] { $"{KnownProperties.AndroidSupportedAbis}=x86" }; + var parameters = Builder.UseDotNet ? + new [] { $"{KnownProperties.RuntimeIdentifier}=android.21-x86" } : + new [] { $"{KnownProperties.AndroidSupportedAbis}=x86" }; b.Build (proj, parameters: parameters, doNotCleanupOnUpdate: true); } } 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..5f9b51a8ee5 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 ("dotnet-ignore")] public class MSBuildSdkExtrasTests : BaseTest { [Test] 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 caefd451dc7..cc10e0f6fe7 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 @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using NUnit.Framework; using Xamarin.ProjectTools; @@ -431,7 +431,7 @@ public void VersionCodeTests (bool seperateApk, string abis, string versionCode, proj.SetProperty ("Foo", "1"); proj.SetProperty (proj.ReleaseProperties, KnownProperties.AndroidCreatePackagePerAbi, seperateApk); if (!string.IsNullOrEmpty (abis)) - proj.SetProperty (proj.ReleaseProperties, KnownProperties.AndroidSupportedAbis, abis); + proj.SetAndroidSupportedAbis (abis); if (!string.IsNullOrEmpty (versionCodePattern)) proj.SetProperty (proj.ReleaseProperties, "AndroidVersionCodePattern", versionCodePattern); else 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 71db497fc72..a3a33e16d50 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 ("mono-symbolicate")] [TestCaseSource (nameof(ManagedSymbolsArchiveSource))] public void CheckManagedSymbolsArchive (bool isRelease, bool monoSymbolArchive, string packageFormat) { @@ -35,8 +36,8 @@ public void CheckManagedSymbolsArchive (bool isRelease, bool monoSymbolArchive, }; proj.SetProperty (proj.ReleaseProperties, "MonoSymbolArchive", monoSymbolArchive); proj.SetProperty (proj.ReleaseProperties, KnownProperties.AndroidCreatePackagePerAbi, "true"); - proj.SetProperty (proj.ReleaseProperties, KnownProperties.AndroidSupportedAbis, "armeabi-v7a;x86"); proj.SetProperty (proj.ReleaseProperties, "AndroidPackageFormat", packageFormat); + proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86"); using (var b = CreateApkBuilder ()) { b.Verbosity = Microsoft.Build.Framework.LoggerVerbosity.Diagnostic; b.ThrowOnBuildFailure = false; @@ -131,7 +132,7 @@ public void CheckIncludedNativeLibraries ([Values (true, false)] bool compressNa }; proj.PackageReferences.Add(KnownPackages.SQLitePCLRaw_Core); proj.SetProperty ("AndroidUseAapt2", useAapt2.ToString ()); - proj.SetProperty(proj.ReleaseProperties, KnownProperties.AndroidSupportedAbis, "x86"); + proj.SetAndroidSupportedAbis ("x86"); proj.SetProperty (proj.ReleaseProperties, "AndroidStoreUncompressedFileExtensions", compressNativeLibraries ? "" : "so"); using (var b = CreateApkBuilder (Path.Combine ("temp", TestContext.CurrentContext.Test.Name))) { b.Verbosity = Microsoft.Build.Framework.LoggerVerbosity.Diagnostic; @@ -315,7 +316,7 @@ public void CheckSignApk ([Values(true, false)] bool useApkSigner, [Values(true, proj.SetProperty (proj.ReleaseProperties, "AndroidSigningKeyPass", pass); proj.SetProperty (proj.ReleaseProperties, "AndroidSigningStorePass", pass); proj.SetProperty (proj.ReleaseProperties, KnownProperties.AndroidCreatePackagePerAbi, perAbiApk); - proj.SetProperty (proj.ReleaseProperties, KnownProperties.AndroidSupportedAbis, "armeabi-v7a;x86"); + 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"); @@ -369,7 +370,7 @@ public void CheckAapt2WarningsDoNotGenerateErrors () proj.PackageReferences.Add (KnownPackages.SupportV7CardView_27_0_2_1); proj.PackageReferences.Add (KnownPackages.SupportV7MediaRouter_27_0_2_1); proj.SetProperty (proj.ReleaseProperties, KnownProperties.AndroidCreatePackagePerAbi, true); - proj.SetProperty (proj.ReleaseProperties, KnownProperties.AndroidSupportedAbis, "armeabi-v7a;x86"); + proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86"); using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) { if (!b.TargetFrameworkExists (proj.TargetFrameworkVersion)) Assert.Ignore ($"Skipped as {proj.TargetFrameworkVersion} not available."); @@ -559,7 +560,7 @@ protected override void OnCreate (Bundle bundle) } } }"; - app.SetProperty (KnownProperties.AndroidSupportedAbis, "x86;armeabi-v7a"); + app.SetAndroidSupportedAbis ("x86", "armeabi-v7a"); var expectedFiles = new string [] { "Java.Interop.dll", "Mono.Android.dll", diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/BundleToolTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/BundleToolTests.cs index d545d82e4fe..6dfa150568f 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/BundleToolTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/BundleToolTests.cs @@ -69,8 +69,7 @@ public void OneTimeSetUp () //NOTE: this is here to enable adb shell run-as app.AndroidManifest = app.AndroidManifest.Replace (" (); + foreach (var androidAbi in androidAbis) { + if (androidAbi == "armeabi-v7a") { + abis.Add ("android.21-arm"); + } else if (androidAbi == "arm64-v8a") { + abis.Add ("android.21-arm64"); + } else if (androidAbi == "x86") { + abis.Add ("android.21-x86"); + } else if (androidAbi == "x86_64") { + abis.Add ("android.21-x64"); + } + } + project.SetProperty (KnownProperties.RuntimeIdentifiers, string.Join (";", abis)); + } } } diff --git a/tests/MSBuildDeviceIntegration/Tests/AotProfileTests.cs b/tests/MSBuildDeviceIntegration/Tests/AotProfileTests.cs index a1041115005..324563edcaa 100644 --- a/tests/MSBuildDeviceIntegration/Tests/AotProfileTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/AotProfileTests.cs @@ -23,7 +23,7 @@ public void BuildBasicApplicationAndAotProfileIt () Assert.Ignore ("Skipping test. No devices available."); var proj = new XamarinAndroidApplicationProject () { IsRelease = true }; - proj.SetProperty (KnownProperties.AndroidSupportedAbis, "armeabi-v7a;x86"); + proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86"); var port = 9000 + new Random ().Next (1000); proj.SetProperty ("AndroidAotProfilerPort", port.ToString ()); proj.AndroidManifest = string.Format (PermissionManifest, proj.PackageName); diff --git a/tests/MSBuildDeviceIntegration/Tests/BugzillaTests.cs b/tests/MSBuildDeviceIntegration/Tests/BugzillaTests.cs index 9ca73150508..173836cb9f7 100644 --- a/tests/MSBuildDeviceIntegration/Tests/BugzillaTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/BugzillaTests.cs @@ -38,7 +38,7 @@ public void GlobalLayoutEvent_ShouldRegisterAndFire_OnActivityLaunch ([Values (f IsRelease = isRelease, }; if (isRelease || !CommercialBuildAvailable) { - proj.SetProperty (KnownProperties.AndroidSupportedAbis, "armeabi-v7a;arm64-v8a;x86"); + proj.SetAndroidSupportedAbis ("armeabi-v7a", "arm64-v8a", "x86"); } else { proj.AndroidManifest = proj.AndroidManifest.Replace ("", ""); } diff --git a/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs b/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs index b675b7d82bf..5e6af6115ab 100755 --- a/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs +++ b/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs @@ -43,8 +43,7 @@ public void ApplicationRunsWithoutDebugger ([Values (false, true)] bool isReleas IsRelease = isRelease, }; if (isRelease || !CommercialBuildAvailable) { - var abis = new string [] { "armeabi-v7a", "x86" }; - proj.SetProperty (KnownProperties.AndroidSupportedAbis, string.Join (";", abis)); + proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86"); } proj.SetDefaultTargetDevice (); using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) { @@ -76,8 +75,7 @@ public void ClassLibraryMainLauncherRuns () ProjectName = "MyApp", }; if (!CommercialBuildAvailable) { - var abis = new string [] { "armeabi-v7a", "x86" }; - app.SetProperty (KnownProperties.AndroidSupportedAbis, string.Join (";", abis)); + app.SetAndroidSupportedAbis ("armeabi-v7a", "x86"); } app.SetDefaultTargetDevice (); @@ -175,8 +173,7 @@ public void CustomApplicationRunsWithDebuggerAndBreaks (bool useSharedRuntime, b IsRelease = false, AndroidFastDeploymentType = fastDevType, }; - var abis = new string [] { "armeabi-v7a", "x86" }; - proj.SetProperty (KnownProperties.AndroidSupportedAbis, string.Join (";", abis)); + proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86"); proj.SetProperty (KnownProperties.AndroidUseSharedRuntime, useSharedRuntime.ToString ()); proj.SetProperty ("EmbedAssembliesIntoApk", embedAssemblies.ToString ()); proj.SetDefaultTargetDevice (); @@ -336,8 +333,7 @@ public void ApplicationRunsWithDebuggerAndBreaks (bool useSharedRuntime, bool em EmbedAssembliesIntoApk = embedAssemblies, AndroidFastDeploymentType = fastDevType }; - var abis = new string [] { "armeabi-v7a", "x86" }; - proj.SetProperty (KnownProperties.AndroidSupportedAbis, string.Join (";", abis)); + proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86"); if (allowDeltaInstall) proj.SetProperty (KnownProperties._AndroidAllowDeltaInstall, "true"); proj.SetDefaultTargetDevice (); diff --git a/tests/MSBuildDeviceIntegration/Tests/DeploymentTest.cs b/tests/MSBuildDeviceIntegration/Tests/DeploymentTest.cs index e9f7e645971..0f139a383ac 100644 --- a/tests/MSBuildDeviceIntegration/Tests/DeploymentTest.cs +++ b/tests/MSBuildDeviceIntegration/Tests/DeploymentTest.cs @@ -37,7 +37,7 @@ public void BeforeDeploymentTests () } proj = new XamarinFormsAndroidApplicationProject (); - proj.SetProperty (KnownProperties.AndroidSupportedAbis, "armeabi-v7a;x86"); + proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86"); var mainPage = proj.Sources.First (x => x.Include () == "MainPage.xaml.cs"); var source = mainPage.TextContent ().Replace ("InitializeComponent ();", @"InitializeComponent (); Console.WriteLine ($""TimeZoneInfo={TimeZoneInfo.Local.DisplayName}""); diff --git a/tests/MSBuildDeviceIntegration/Tests/InstallTests.cs b/tests/MSBuildDeviceIntegration/Tests/InstallTests.cs index 437e49c4b58..35929c165f1 100644 --- a/tests/MSBuildDeviceIntegration/Tests/InstallTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/InstallTests.cs @@ -39,8 +39,7 @@ public void ReInstallIfUserUninstalled ([Values (false, true)] bool isRelease) IsRelease = isRelease, }; if (isRelease) { - var abis = new string [] { "armeabi-v7a", "x86" }; - proj.SetProperty (KnownProperties.AndroidSupportedAbis, string.Join (";", abis)); + proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86"); } using (var builder = CreateApkBuilder (Path.Combine ("temp", TestContext.CurrentContext.Test.Name))) { builder.Verbosity = LoggerVerbosity.Diagnostic; @@ -73,8 +72,7 @@ public void InstallAndUnInstall ([Values (false, true)] bool isRelease) IsRelease = isRelease, }; if (isRelease) { - var abis = new string [] { "armeabi-v7a", "x86" }; - proj.SetProperty (KnownProperties.AndroidSupportedAbis, string.Join (";", abis)); + proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86"); } using (var builder = CreateApkBuilder (Path.Combine ("temp", TestContext.CurrentContext.Test.Name))) { builder.Verbosity = LoggerVerbosity.Diagnostic; @@ -118,8 +116,7 @@ public void ChangeKeystoreRedeploy () } var proj = new XamarinAndroidApplicationProject (); - var abis = new string [] { "armeabi-v7a", "x86" }; - proj.SetProperty (KnownProperties.AndroidSupportedAbis, string.Join (";", abis)); + proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86"); using (var builder = CreateApkBuilder ()) { // Use the default debug.keystore XA generates Assert.IsTrue (builder.Install (proj), "first install should succeed."); @@ -152,8 +149,7 @@ public void SwitchConfigurationsShouldRedeploy () var proj = new XamarinAndroidApplicationProject () { IsRelease = false, }; - var abis = new string [] { "armeabi-v7a", "x86" }; - proj.SetProperty (KnownProperties.AndroidSupportedAbis, string.Join (";", abis)); + proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86"); using (var builder = CreateApkBuilder (Path.Combine ("temp", TestContext.CurrentContext.Test.Name))) { builder.Verbosity = LoggerVerbosity.Diagnostic; Assert.IsTrue (builder.Build (proj)); @@ -224,8 +220,8 @@ public void InstallWithoutSharedRuntime () proj.SetProperty (proj.ReleaseProperties, "DebugType", "none"); proj.SetProperty (proj.ReleaseProperties, "AndroidUseSharedRuntime", false); proj.RemoveProperty (proj.ReleaseProperties, "EmbedAssembliesIntoApk"); - var abis = new string [] { "armeabi-v7a", "x86" }; - proj.SetProperty (KnownProperties.AndroidSupportedAbis, string.Join (";", abis)); + var abis = new [] { "armeabi-v7a", "x86" }; + proj.SetAndroidSupportedAbis (abis); using (var builder = CreateApkBuilder (Path.Combine ("temp", TestContext.CurrentContext.Test.Name), false, false)) { builder.Verbosity = LoggerVerbosity.Diagnostic; if (RunAdbCommand ("shell pm list packages Mono.Android.DebugRuntime").Trim ().Length != 0) @@ -282,7 +278,7 @@ public void InstallErrorCode () AndroidUseSharedRuntime = false, EmbedAssembliesIntoApk = true, }; - proj.SetProperty (proj.DebugProperties, KnownProperties.AndroidSupportedAbis, abi); + proj.SetAndroidSupportedAbis (abi); using (var builder = CreateApkBuilder (Path.Combine ("temp", TestContext.CurrentContext.Test.Name))) { builder.ThrowOnBuildFailure = false; @@ -329,8 +325,7 @@ public void ToggleFastDev () //Now toggle FastDev to OFF proj.AndroidUseSharedRuntime = false; proj.EmbedAssembliesIntoApk = true; - var abis = new string [] { "armeabi-v7a", "x86" }; - proj.SetProperty (KnownProperties.AndroidSupportedAbis, string.Join (";", abis)); + proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86"); Assert.IsTrue (builder.Install (proj), "Second install should have succeeded."); @@ -429,8 +424,7 @@ public void TestAndroidStoreKey (bool useApkSigner, bool isRelease, string packa proj.SetProperty ("AndroidSigningStorePass", password); proj.SetProperty ("AndroidSigningKeyPass", password); } - var abis = new string [] { "armeabi-v7a", "x86" }; - proj.SetProperty (KnownProperties.AndroidSupportedAbis, string.Join (";", abis)); + proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86"); proj.SetProperty ("AndroidKeyStore", androidKeyStore); proj.SetProperty ("AndroidSigningKeyStore", "test.keystore"); proj.SetProperty ("AndroidSigningKeyAlias", "mykey"); diff --git a/tests/MSBuildDeviceIntegration/Tests/MonoAndroidExportTest.cs b/tests/MSBuildDeviceIntegration/Tests/MonoAndroidExportTest.cs index 350e33666d4..8dd70962047 100644 --- a/tests/MSBuildDeviceIntegration/Tests/MonoAndroidExportTest.cs +++ b/tests/MSBuildDeviceIntegration/Tests/MonoAndroidExportTest.cs @@ -119,8 +119,7 @@ protected override void OnCreate (Bundle bundle) } } }"; - var abis = new string [] { "armeabi-v7a", "x86" }; - proj.SetProperty (KnownProperties.AndroidSupportedAbis, string.Join (";", abis)); + proj.SetAndroidSupportedAbis ("armeabi-v7a", "x86"); proj.SetProperty (KnownProperties.AndroidUseSharedRuntime, useSharedRuntime.ToString ()); proj.SetProperty ("EmbedAssembliesIntoApk", embedAssemblies.ToString ()); proj.SetDefaultTargetDevice (); diff --git a/tests/MSBuildDeviceIntegration/Tests/XASdkDeployTests.cs b/tests/MSBuildDeviceIntegration/Tests/XASdkDeployTests.cs index 2e3f34d5cc6..8362c4c2c30 100644 --- a/tests/MSBuildDeviceIntegration/Tests/XASdkDeployTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/XASdkDeployTests.cs @@ -12,6 +12,7 @@ namespace Xamarin.Android.Build.Tests { + [Category ("dotnet-ignore")] // These don't need to run under `--params dotnet=true` [NonParallelizable] public class XASdkDeployTests : DeviceTest {