diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.LlvmIr.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.LlvmIr.targets index 7bb826023f8..e83b0cb91ea 100644 --- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.LlvmIr.targets +++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.LlvmIr.targets @@ -50,12 +50,16 @@ <_MergedManifestDocuments Condition=" '$(AndroidManifestMerger)' == 'legacy' " Include="@(ExtractedManifestDocuments)" /> + + <_AndroidResolvedAssembliesToScan + Include="@(_ResolvedAssemblies)" + Condition=" !$([System.String]::Copy('%(_ResolvedAssemblies.Filename)').ToLowerInvariant().EndsWith('.resources')) " /> @@ -63,7 +67,7 @@ @@ -95,7 +99,7 @@ EmitLlvmIrComments="$(_AndroidEmitLlvmIrComments)" EnableMarshalMethods="$(_AndroidUseMarshalMethods)" IntermediateOutputDirectory="$(IntermediateOutputPath)" - ResolvedAssemblies="@(_ResolvedAssemblies)" + ResolvedAssemblies="@(_AndroidResolvedAssembliesToScan)" SkipJniAddNativeMethodRegistrationAttributeScan="$(_SkipJniAddNativeMethodRegistrationAttributeScan)" SupportedAbis="@(_BuildTargetAbis)" TypemapImplementation="$(AndroidTypeMapImplementation)" 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 ee0ff31d17e..48013d43bfc 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 @@ -93,27 +93,62 @@ public void CheckDebugModeWithTrimming ([Values (AndroidRuntime.CoreCLR)] Androi string.Join (Environment.NewLine, missingFiles))); } - [Test] [NonParallelizable] // Commonly fails NuGet restore - public void CheckIncludedAssemblies ([Values (false, true)] bool usesAssemblyStores, [Values (AndroidRuntime.CoreCLR)] AndroidRuntime runtime) + [TestCase (false, AndroidRuntime.CoreCLR)] + [TestCase (true, AndroidRuntime.CoreCLR)] + [TestCase (true, AndroidRuntime.MonoVM)] + public void CheckIncludedAssemblies (bool usesAssemblyStores, AndroidRuntime runtime) { if (!usesAssemblyStores && runtime == AndroidRuntime.CoreCLR) { Assert.Ignore ("CoreCLR only supports builds with assembly stores."); return; } + var injectPackagedSatellite = new Import (() => "InjectPackagedSatellite.targets") { + TextContent = () => +""" + + + + <_ResolvedAssemblies Include="@(ReferenceSatellitePaths)"> + <_InjectedPackagedSatellite>true + + + + + + + <_ResolvedAssemblies + Remove="@(_ResolvedAssemblies)" + Condition=" '%(_ResolvedAssemblies._InjectedPackagedSatellite)' == 'true' " /> + + + +""" + }; var proj = new XamarinAndroidApplicationProject { - IsRelease = true + IsRelease = true, + Imports = { injectPackagedSatellite }, }; AndroidTargetArch[] supportedArches = new[] { runtime switch { - AndroidRuntime.MonoVM => AndroidTargetArch.Arm, + AndroidRuntime.MonoVM => AndroidTargetArch.Arm64, AndroidRuntime.CoreCLR => AndroidTargetArch.Arm64, _ => throw new NotSupportedException ($"Unsupported runtime '{runtime}'") } }; proj.SetRuntime (runtime); + if (runtime == AndroidRuntime.MonoVM) { + proj.SetProperty ("_DisableCheckForUnsupportedMonoMobileRuntime", "true"); + } proj.SetProperty ("AndroidUseAssemblyStore", usesAssemblyStores.ToString ()); proj.SetRuntimeIdentifiers (supportedArches); proj.PackageReferences.Add (new Package { @@ -157,6 +192,10 @@ public void CheckIncludedAssemblies ([Values (false, true)] bool usesAssemblySto using (var b = CreateApkBuilder ()) { Assert.IsTrue (b.Build (proj), "build should have succeeded."); + if (runtime == AndroidRuntime.MonoVM) { + Assert.IsTrue (b.LastBuildOutput.Any (line => line.Contains ("InjectedPackagedSatellite=", StringComparison.Ordinal)), + "The test should expose a packaged satellite assembly to Java stub generation."); + } var apk = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath, $"{proj.PackageName}-Signed.apk"); var helper = new ArchiveAssemblyHelper (apk, usesAssemblyStores);