From a10fe2aa30a070fe4a837a7e41c45b8d500a7740 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Thu, 21 Nov 2024 10:36:35 -0600 Subject: [PATCH 1/3] [build] produce multiple "flavors" of runtime packs Right now our runtime packs are all identical for each .NET "runtime", but we want to be able to produce different packs, such as: Microsoft.Android.Runtime.Mono.35.android-arm Microsoft.Android.Runtime.Mono.35.android-arm64 Microsoft.Android.Runtime.Mono.35.android-x86 Microsoft.Android.Runtime.Mono.35.android-x64 Microsoft.Android.Runtime.NativeAOT.35.android-arm Microsoft.Android.Runtime.NativeAOT.35.android-arm64 Microsoft.Android.Runtime.NativeAOT.35.android-x86 Microsoft.Android.Runtime.NativeAOT.35.android-x64 Currently, the contents of all these packs are identical, but this is an initial step to build multiple packs. The plan is for the workload to only install the "Mono" packs, and the "NativeAOT" packs can be restored via NuGet. --- .../create-packs/Directory.Build.targets | 20 ++++++++++--------- .../Microsoft.Android.Runtime.proj | 5 +++-- ...oft.Android.Sdk.BundledVersions.in.targets | 4 +++- .../WorkloadManifest.in.json | 16 +++++++-------- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/build-tools/create-packs/Directory.Build.targets b/build-tools/create-packs/Directory.Build.targets index c06a6b6000d..fc70e22ed83 100644 --- a/build-tools/create-packs/Directory.Build.targets +++ b/build-tools/create-packs/Directory.Build.targets @@ -54,26 +54,28 @@ + + + <_AndroidRuntimeNames Include="Mono;NativeAOT" /> + <_AndroidRIDs Include="android-arm;android-arm64;android-x86;android-x64" Runtime="%(_AndroidRuntimeNames.Identity)" /> + + + - - - - + - - - - + DependsOnTargets="DeleteExtractedWorkloadPacks;_SetGlobalProperties;GetXAVersionInfo;_CleanNuGetDirectory;_CreateItemGroups;_CreatePreviewPacks;_CreateDefaultRefPack"> + diff --git a/build-tools/create-packs/Microsoft.Android.Runtime.proj b/build-tools/create-packs/Microsoft.Android.Runtime.proj index 6ccb3fa4847..99969ba29f6 100644 --- a/build-tools/create-packs/Microsoft.Android.Runtime.proj +++ b/build-tools/create-packs/Microsoft.Android.Runtime.proj @@ -2,7 +2,7 @@ *********************************************************************************************** Microsoft.Android.Runtime.proj -This project file is used to create Microsoft.Android.Runtime.[API].[RID] NuGets, which are +This project file is used to create Microsoft.Android.Runtime.[Mono|NativeAOT|etc.].[API].[RID] NuGets, which are runtime packs that contain the assets required for a self-contained publish of projects that use the Microsoft.Android framework in .NET 6+. *********************************************************************************************** @@ -11,7 +11,8 @@ projects that use the Microsoft.Android framework in .NET 6+. android-arm64 - Microsoft.Android.Runtime.$(AndroidApiLevel).$(AndroidRID) + Mono + Microsoft.Android.Runtime.$(AndroidRuntime).$(AndroidApiLevel).$(AndroidRID) Microsoft.Android runtime components for API $(AndroidApiLevel). Please do not reference directly. <_AndroidRuntimePackAssemblyPath>runtimes\$(AndroidRID)\lib\$(DotNetTargetFramework) <_AndroidRuntimePackNativePath>runtimes\$(AndroidRID)\native diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/in/Microsoft.Android.Sdk.BundledVersions.in.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/in/Microsoft.Android.Sdk.BundledVersions.in.targets index 4906a1fa691..2d4ebccd929 100644 --- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/in/Microsoft.Android.Sdk.BundledVersions.in.targets +++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/in/Microsoft.Android.Sdk.BundledVersions.in.targets @@ -20,6 +20,8 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and <_AndroidTargetingPackId Condition=" '$(_AndroidTargetingPackId)' != '$(_AndroidLatestStableApiLevel)' and '$(_AndroidTargetingPackId)' != '$(_AndroidLatestUnstableApiLevel)' ">$(_AndroidLatestStableApiLevel) <_AndroidRuntimePackId Condition=" '$(_AndroidRuntimePackId)' == '' ">$(_AndroidTargetingPackId) <_AndroidRuntimePackId Condition=" '$(_AndroidRuntimePackId)' != '$(_AndroidLatestStableApiLevel)' and '$(_AndroidRuntimePackId)' != '$(_AndroidLatestUnstableApiLevel)' ">$(_AndroidLatestStableApiLevel) + <_AndroidRuntimePackRuntime Condition=" '$(PublishAot)' == 'true' ">NativeAOT + <_AndroidRuntimePackRuntime Condition=" '$(_AndroidRuntimePackRuntime)' == '' ">Mono diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.NET.Sdk.Android/WorkloadManifest.in.json b/src/Xamarin.Android.Build.Tasks/Microsoft.NET.Sdk.Android/WorkloadManifest.in.json index dda3c79df31..6efa0c1fce9 100644 --- a/src/Xamarin.Android.Build.Tasks/Microsoft.NET.Sdk.Android/WorkloadManifest.in.json +++ b/src/Xamarin.Android.Build.Tasks/Microsoft.NET.Sdk.Android/WorkloadManifest.in.json @@ -7,10 +7,10 @@ "Microsoft.Android.Sdk.net9", "Microsoft.Android.Sdk.net8", "Microsoft.Android.Ref.35", - "Microsoft.Android.Runtime.35.android-arm", - "Microsoft.Android.Runtime.35.android-arm64", - "Microsoft.Android.Runtime.35.android-x86", - "Microsoft.Android.Runtime.35.android-x64", + "Microsoft.Android.Runtime.Mono.35.android-arm", + "Microsoft.Android.Runtime.Mono.35.android-arm64", + "Microsoft.Android.Runtime.Mono.35.android-x86", + "Microsoft.Android.Runtime.Mono.35.android-x64", "Microsoft.Android.Templates" ], "platforms": [ "win-x64", "win-arm64", "linux-x64", "linux-arm64", "osx-x64", "osx-arm64" ], @@ -53,19 +53,19 @@ "kind": "framework", "version": "@WORKLOAD_VERSION@" }, - "Microsoft.Android.Runtime.35.android-arm": { + "Microsoft.Android.Runtime.Mono.35.android-arm": { "kind": "framework", "version": "@WORKLOAD_VERSION@" }, - "Microsoft.Android.Runtime.35.android-arm64": { + "Microsoft.Android.Runtime.Mono.35.android-arm64": { "kind": "framework", "version": "@WORKLOAD_VERSION@" }, - "Microsoft.Android.Runtime.35.android-x86": { + "Microsoft.Android.Runtime.Mono.35.android-x86": { "kind": "framework", "version": "@WORKLOAD_VERSION@" }, - "Microsoft.Android.Runtime.35.android-x64": { + "Microsoft.Android.Runtime.Mono.35.android-x64": { "kind": "framework", "version": "@WORKLOAD_VERSION@" }, From 2acfc8bc96a2c6ac09de2b4cd3e8b917c4c45bb5 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Thu, 21 Nov 2024 13:19:40 -0600 Subject: [PATCH 2/3] Update XASdkTests.cs --- .../Tests/Xamarin.Android.Build.Tests/XASdkTests.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 4fbe5439758..54998e3319a 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 @@ -239,8 +239,10 @@ public void DotNetPublish ([Values (false, true)] bool isRelease, [ValueSource(n var expectedMonoAndroidRefPath = Path.Combine (refDirectory, "ref", dotnetVersion, "Mono.Android.dll"); Assert.IsTrue (dotnet.LastBuildOutput.ContainsText (expectedMonoAndroidRefPath), $"Build should be using {expectedMonoAndroidRefPath}"); + // TODO: We could parameterize this later + const string runtime = "Mono"; var runtimeApiLevel = (apiLevel == XABuildConfig.AndroidDefaultTargetDotnetApiLevel && apiLevel < XABuildConfig.AndroidLatestStableApiLevel) ? XABuildConfig.AndroidLatestStableApiLevel : apiLevel; - var runtimeDirectory = Directory.GetDirectories (Path.Combine (TestEnvironment.DotNetPreviewPacksDirectory, $"Microsoft.Android.Runtime.{runtimeApiLevel}.{runtimeIdentifier}")).LastOrDefault (); + var runtimeDirectory = Directory.GetDirectories (Path.Combine (TestEnvironment.DotNetPreviewPacksDirectory, $"Microsoft.Android.Runtime.{runtime}.{runtimeApiLevel}.{runtimeIdentifier}")).LastOrDefault (); var expectedMonoAndroidRuntimePath = Path.Combine (runtimeDirectory, "runtimes", runtimeIdentifier, "lib", dotnetVersion, "Mono.Android.dll"); Assert.IsTrue (dotnet.LastBuildOutput.ContainsText (expectedMonoAndroidRuntimePath), $"Build should be using {expectedMonoAndroidRuntimePath}"); } From 32937dab7fe290793a6a7e89f45c4892a8e0bb1f Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Thu, 21 Nov 2024 13:55:10 -0600 Subject: [PATCH 3/3] Add `.Mono` in more places --- Configuration.props | 8 ++++---- build-tools/create-packs/ConfigureLocalWorkload.targets | 6 +++--- build-tools/create-packs/Directory.Build.targets | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Configuration.props b/Configuration.props index 3c139ac2659..cb84e702081 100644 --- a/Configuration.props +++ b/Configuration.props @@ -63,10 +63,10 @@ <_MonoAndroidNETOutputRoot>$(XAInstallPrefix)xbuild-frameworks\Microsoft.Android\ <_MonoAndroidNETDefaultOutDir>$(_MonoAndroidNETOutputRoot)$(AndroidApiLevel)\ $(BuildOutputDirectory)lib\packs\Microsoft.Android.Ref.$(AndroidApiLevel)\$(AndroidPackVersion)\ref\$(DotNetTargetFramework)\ - $(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.$(AndroidApiLevel).android-arm\$(AndroidPackVersion)\runtimes\android-arm\ - $(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.$(AndroidApiLevel).android-arm64\$(AndroidPackVersion)\runtimes\android-arm64\ - $(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.$(AndroidApiLevel).android-x86\$(AndroidPackVersion)\runtimes\android-x86\ - $(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.$(AndroidApiLevel).android-x64\$(AndroidPackVersion)\runtimes\android-x64\ + $(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.Mono.$(AndroidApiLevel).android-arm\$(AndroidPackVersion)\runtimes\android-arm\ + $(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.Mono.$(AndroidApiLevel).android-arm64\$(AndroidPackVersion)\runtimes\android-arm64\ + $(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.Mono.$(AndroidApiLevel).android-x86\$(AndroidPackVersion)\runtimes\android-x86\ + $(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.Mono.$(AndroidApiLevel).android-x64\$(AndroidPackVersion)\runtimes\android-x64\ $(BuildOutputDirectory)lib\packs\$(MicrosoftAndroidSdkPackName)\$(AndroidPackVersion)\ $(MicrosoftAndroidSdkPackDir)\tools\ $(BuildOutputDirectory)lib\packs\Microsoft.Android.Ref.$(AndroidApiLevel)\$(AndroidPackVersion)\analyzers\dotnet\cs\ diff --git a/build-tools/create-packs/ConfigureLocalWorkload.targets b/build-tools/create-packs/ConfigureLocalWorkload.targets index 6a4a6b82445..00a37a8a9cc 100644 --- a/build-tools/create-packs/ConfigureLocalWorkload.targets +++ b/build-tools/create-packs/ConfigureLocalWorkload.targets @@ -10,9 +10,9 @@ <_RuntimeListInputs Include="$(MicrosoftAndroidArm64PackDir)**" /> <_RuntimeListInputs Include="$(MicrosoftAndroidx86PackDir)**" /> <_RuntimeListInputs Include="$(MicrosoftAndroidx64PackDir)**" /> - <_RuntimeListOutputs Include="@(AndroidSupportedTargetJitAbi->'$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.$(AndroidDefaultTargetDotnetApiLevel).%(AndroidRID)\$(AndroidPackVersion)\data\RuntimeList.xml')" AndroidRID="%(AndroidRID)" /> - <_RuntimeListOutputs Include="@(AndroidSupportedTargetJitAbi->'$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.$(AndroidLatestStableApiLevel).%(AndroidRID)\$(AndroidPackVersion)\data\RuntimeList.xml')" AndroidRID="%(AndroidRID)" /> - <_RuntimeListOutputs Include="@(AndroidSupportedTargetJitAbi->'$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.$(AndroidLatestUnstableApiLevel).%(AndroidRID)\$(AndroidPackVersion)\data\RuntimeList.xml')" AndroidRID="%(AndroidRID)" /> + <_RuntimeListOutputs Include="@(AndroidSupportedTargetJitAbi->'$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.Mono.$(AndroidDefaultTargetDotnetApiLevel).%(AndroidRID)\$(AndroidPackVersion)\data\RuntimeList.xml')" AndroidRID="%(AndroidRID)" /> + <_RuntimeListOutputs Include="@(AndroidSupportedTargetJitAbi->'$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.Mono.$(AndroidLatestStableApiLevel).%(AndroidRID)\$(AndroidPackVersion)\data\RuntimeList.xml')" AndroidRID="%(AndroidRID)" /> + <_RuntimeListOutputs Include="@(AndroidSupportedTargetJitAbi->'$(BuildOutputDirectory)lib\packs\Microsoft.Android.Runtime.Mono.$(AndroidLatestUnstableApiLevel).%(AndroidRID)\$(AndroidPackVersion)\data\RuntimeList.xml')" AndroidRID="%(AndroidRID)" /> <_TemplatesInputs Include="$(XamarinAndroidSourcePath)src\Microsoft.Android.Templates\**" /> <_TemplatesOutputs Include="$(BuildOutputDirectory)lib\template-packs\microsoft.android.templates.$(AndroidPackVersion).nupkg" /> diff --git a/build-tools/create-packs/Directory.Build.targets b/build-tools/create-packs/Directory.Build.targets index fc70e22ed83..85fdf568069 100644 --- a/build-tools/create-packs/Directory.Build.targets +++ b/build-tools/create-packs/Directory.Build.targets @@ -150,10 +150,10 @@ <_PackFoldersToDelete Include="$(DotNetPreviewPath)sdk-manifests\$(DotNetSdkManifestsFolder)\workloadsets" /> <_PackFoldersToDelete Include="$(DotNetPreviewPath)sdk-manifests\$(DotNetSdkManifestsFolder)\microsoft.net.sdk.android" /> <_PackFoldersToDelete Include="$(DotNetPreviewPath)packs\Microsoft.Android.Ref.%(_PackApiLevels.Identity)" /> - <_PackFoldersToDelete Include="$(DotNetPreviewPath)packs\Microsoft.Android.Runtime.%(_PackApiLevels.Identity).android-arm" /> - <_PackFoldersToDelete Include="$(DotNetPreviewPath)packs\Microsoft.Android.Runtime.%(_PackApiLevels.Identity).android-arm64" /> - <_PackFoldersToDelete Include="$(DotNetPreviewPath)packs\Microsoft.Android.Runtime.%(_PackApiLevels.Identity).android-x86" /> - <_PackFoldersToDelete Include="$(DotNetPreviewPath)packs\Microsoft.Android.Runtime.%(_PackApiLevels.Identity).android-x64" /> + <_PackFoldersToDelete Include="$(DotNetPreviewPath)packs\Microsoft.Android.Runtime.Mono.%(_PackApiLevels.Identity).android-arm" /> + <_PackFoldersToDelete Include="$(DotNetPreviewPath)packs\Microsoft.Android.Runtime.Mono.%(_PackApiLevels.Identity).android-arm64" /> + <_PackFoldersToDelete Include="$(DotNetPreviewPath)packs\Microsoft.Android.Runtime.Mono.%(_PackApiLevels.Identity).android-x86" /> + <_PackFoldersToDelete Include="$(DotNetPreviewPath)packs\Microsoft.Android.Runtime.Mono.%(_PackApiLevels.Identity).android-x64" /> <_PackFoldersToDelete Include="$(DotNetPreviewPath)packs\Microsoft.Android.Sdk.Darwin" /> <_PackFoldersToDelete Include="$(DotNetPreviewPath)packs\Microsoft.Android.Sdk.Linux" /> <_PackFoldersToDelete Include="$(DotNetPreviewPath)packs\Microsoft.Android.Sdk.Windows" />