From 600e993d2146662cd072b9ffeb9163a36822eb23 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Tue, 6 Jul 2021 18:36:25 -0500 Subject: [PATCH] [One .NET] `dotnet workload install android` or android-aot (#6045) Context: https://github.com/dotnet/maui/tree/ef4518bf502ffa6760625c4cb53fa0cb015bc6d1/src/Workload#net-maui-workload-ids Right now to install the Android workload you would run: dotnet workload install microsoft-android-sdk-full Shorten this to be: dotnet workload install android We can also create a new workload that extends `android`, and includes AOT support: dotnet workload install android-aot To test this behavior on our CI, I reworked the `ExtractWorkloadPacks` MSBuild target to run `dotnet workload install` commands. This should give us more confidence that our workload can be installed -- and that our MSBuild tests will consume the installed workload. Other changes: * Added our `Microsoft.Android.Runtime.*` packs to `WorkloadManifest.json`. This was mostly omitted by mistake; however, runtime packs aren't resolved either due to: https://github.com/dotnet/sdk/issues/14044 * Call `setup-test-environment.yaml` in `dotnet_create_msi` job * Delete `dotnet/metadata` folder in `Step_InstallDotNetPreview` * Add `setup-test-environment.yaml` to another build phase --- build-tools/automation/azure-pipelines.yaml | 20 +++------ .../create-packs/Directory.Build.targets | 44 +++++++++---------- .../Steps/Step_InstallDotNetPreview.cs | 6 +++ .../WorkloadManifest.in.json | 28 +++++++++++- 4 files changed, 60 insertions(+), 38 deletions(-) diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml index 8b282fa4f47..8f1694b6a60 100644 --- a/build-tools/automation/azure-pipelines.yaml +++ b/build-tools/automation/azure-pipelines.yaml @@ -1291,20 +1291,13 @@ stages: workspace: clean: all steps: - - checkout: self - submodules: recursive + - template: yaml-templates/setup-test-environment.yaml + parameters: + xaSourcePath: $(System.DefaultWorkingDirectory)/xamarin-android - checkout: release_scripts clean: true - - template: yaml-templates/use-dot-net.yaml - parameters: - remove_dotnet: true - - - template: yaml-templates/use-dot-net.yaml - parameters: - version: $(DotNetCoreVersion) - - task: DownloadPipelineArtifact@2 inputs: ${{ if eq(variables['MicroBuildSignType'], 'Real') }}: @@ -1397,10 +1390,9 @@ stages: - ${{ if eq(variables['MicroBuildSignType'], 'Real') }}: - group: Publish-Build-Assets steps: - - checkout: self - submodules: recursive - - - template: yaml-templates/use-dot-net.yaml + - template: yaml-templates/setup-test-environment.yaml + parameters: + configuration: $(XA.Build.Configuration) - task: DownloadPipelineArtifact@2 inputs: diff --git a/build-tools/create-packs/Directory.Build.targets b/build-tools/create-packs/Directory.Build.targets index af6092742d7..61233e10a8a 100644 --- a/build-tools/create-packs/Directory.Build.targets +++ b/build-tools/create-packs/Directory.Build.targets @@ -75,12 +75,6 @@ DependsOnTargets="DeleteExtractedWorkloadPacks" > <_WLManifest Include="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned\Microsoft.NET.Sdk.Android.Manifest-*.nupkg" /> - <_WLPacks Include="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned\Microsoft.Android.Sdk.$(HostOS).*.nupkg" /> - <_WLPacks Include="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned\Microsoft.Android.Sdk.BundleTool.*.nupkg" /> - <_WLPacks Include="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned\Microsoft.Android.Ref.*.nupkg" /> - <_WLTemplates Include="$(XamarinAndroidSourcePath)bin\Build$(Configuration)\nuget-unsigned\Microsoft.Android.Templates.*.nupkg" /> - - <_WLPackVersion>@(_WLManifest->'%(Filename)'->Replace('Microsoft.NET.Sdk.Android.Manifest-$(DotNetPreviewVersionBand).', '')) @@ -97,24 +91,30 @@ - - - - - - <_UnixExecutables Include="$(DotNetPreviewPath)packs\Microsoft.Android.Sdk.*\*\tools\$(HostOS)\**\*.*" /> - <_FilesToTouch Include="$(DotNetPreviewPath)sdk-manifests\$(DotNetPreviewVersionBand)\microsoft.net.sdk.android\**" /> - <_FilesToTouch Include="$(DotNetPreviewPath)packs\$([System.String]::Copy('%(_WLPacks.Filename)').Replace('.$(_WLPackVersion)', ''))\$(_WLPackVersion)\**" /> - + + + + <_TempDirectory>$(DotNetPreviewPath)..\.xa-workload-temp-$([System.IO.Path]::GetRandomFileName()) + <_NuGetConfig>$(_TempDirectory)\NuGet.config + <_NuGetContent> + + + + + + + + +]]> + + + - - + diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs b/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs index 30180977df6..641f56c7cd9 100644 --- a/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs +++ b/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs @@ -68,6 +68,12 @@ protected override async Task Execute (Context context) } } + // Delete the metadata folder, which contains old workload data + var metadataPath = Path.Combine (dotnetPath, "metadata"); + if (Directory.Exists (metadataPath)) { + Utilities.DeleteDirectory (metadataPath); + } + if (File.Exists (dotnetTool)) { if (!TestDotNetSdk (dotnetTool)) { Log.WarningLine ($"Attempt to run `dotnet --version` failed, reinstalling the SDK."); 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 c6aba630136..71732354a8b 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 @@ -1,15 +1,23 @@ { "version": "@WORKLOAD_VERSION@", "workloads": { - "microsoft-android-sdk-full": { - "description": "Android SDK", + "android": { + "description": "Microsoft Android SDK for .NET", "packs": [ "Microsoft.Android.Sdk", "Microsoft.Android.Sdk.BundleTool", "Microsoft.Android.Ref", + "Microsoft.Android.Runtime.android-arm", + "Microsoft.Android.Runtime.android-arm64", + "Microsoft.Android.Runtime.android-x86", + "Microsoft.Android.Runtime.android-x64", "Microsoft.Android.Templates" ], "extends" : [ "microsoft-net-runtime-android" ] + }, + "android-aot": { + "description": "Microsoft Android SDK for .NET with AOT support", + "extends" : [ "android", "microsoft-net-runtime-android-aot" ] } }, "packs": { @@ -32,6 +40,22 @@ "kind": "framework", "version": "@WORKLOAD_VERSION@" }, + "Microsoft.Android.Runtime.android-arm": { + "kind": "framework", + "version": "@WORKLOAD_VERSION@" + }, + "Microsoft.Android.Runtime.android-arm64": { + "kind": "framework", + "version": "@WORKLOAD_VERSION@" + }, + "Microsoft.Android.Runtime.android-x86": { + "kind": "framework", + "version": "@WORKLOAD_VERSION@" + }, + "Microsoft.Android.Runtime.android-x64": { + "kind": "framework", + "version": "@WORKLOAD_VERSION@" + }, "Microsoft.Android.Templates": { "kind": "template", "version": "@WORKLOAD_VERSION@"