From 29051d42a431e40da07b2994ac3d43c362f216f9 Mon Sep 17 00:00:00 2001 From: Peter Collins Date: Tue, 30 Aug 2022 08:23:05 -0400 Subject: [PATCH] [ci] Add support to net7.0 for multi-targeting in VS (#7311) Context: https://github.com/xamarin/yaml-templates/pull/180 Context: https://github.com/xamarin/yaml-templates/pull/195 Context: https://github.com/xamarin/yaml-templates/pull/199 Updates the build to use the latest MSI generation template. The v3 template uses the latest changes from arcade which include a large refactoring, support for multi-targeting, and support for workload pack group MSIs. The build will now produce two different VS Drop artifacts. The MSI and VSMAN files generated for SDK packs have been split out into a new `vsdrop-multitarget-signed` artifact, allowing us to include multiple versions of the SDK packs in VS. The `Microsoft.Android.Sdk` pack has been renamed to `Microsoft.Android.Sdk.net7` to allow it to be imported by the .NET 8 workload manifest when the time comes. --- Configuration.props | 2 +- build-tools/automation/azure-pipelines.yaml | 18 +++++++++++++++--- build-tools/create-packs/vs-workload.in.props | 4 ++++ .../WorkloadManifest.in.json | 8 ++++---- .../WorkloadManifest.in.targets | 4 ++-- .../Xamarin.Android.Build.Tests/XASdkTests.cs | 6 +++++- .../Tests/XASdkDeployTests.cs | 15 +++++++++++++++ 7 files changed, 46 insertions(+), 11 deletions(-) diff --git a/Configuration.props b/Configuration.props index ba165078305..53f042f6793 100644 --- a/Configuration.props +++ b/Configuration.props @@ -47,7 +47,7 @@ portable True latest - 32.0.447 + 32.0.465 Windows diff --git a/build-tools/automation/azure-pipelines.yaml b/build-tools/automation/azure-pipelines.yaml index a12aac4bb18..de1b1ddfb2a 100644 --- a/build-tools/automation/azure-pipelines.yaml +++ b/build-tools/automation/azure-pipelines.yaml @@ -1445,7 +1445,7 @@ stages: usePipelineArtifactTasks: true # Check - "Xamarin.Android (Prepare .NET Release Convert NuGet to MSI)" - - template: nuget-msi-convert/job/v2.yml@yaml + - template: nuget-msi-convert/job/v3.yml@yaml parameters: yamlResourceName: yaml dependsOn: sign_net_mac_win @@ -1454,8 +1454,6 @@ stages: !*Darwin* propsArtifactName: $(NuGetArtifactName) signType: $(MicroBuildSignType) - runInParallel: false - useDateTimeVersion: true postConvertSteps: - task: DownloadPipelineArtifact@2 inputs: @@ -1540,6 +1538,20 @@ stages: artifactName: vsdrop-signed downloadPath: $(Build.StagingDirectory)\$(VSDropCommitStatusName) + - template: templates\common\upload-vs-insertion-artifacts.yml@sdk-insertions + parameters: + githubToken: $(GitHub.Token) + githubContext: $(MultiTargetVSDropCommitStatusName) + blobName: $(MultiTargetVSDropCommitStatusName) + packagePrefix: xamarin-android + artifactsPath: $(Build.StagingDirectory)\$(MultiTargetVSDropCommitStatusName) + yamlResourceName: yaml + downloadSteps: + - task: DownloadPipelineArtifact@2 + inputs: + artifactName: vsdrop-multitarget-signed + downloadPath: $(Build.StagingDirectory)\$(MultiTargetVSDropCommitStatusName) + - powershell: >- & dotnet build -v:n -c $(XA.Build.Configuration) -t:PushManifestToBuildAssetRegistry diff --git a/build-tools/create-packs/vs-workload.in.props b/build-tools/create-packs/vs-workload.in.props index a411be24ab1..5e34ffd638e 100644 --- a/build-tools/create-packs/vs-workload.in.props +++ b/build-tools/create-packs/vs-workload.in.props @@ -9,7 +9,11 @@ @PACK_VERSION_SHORT@ + + Android.Manifest + + 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 b594e803baf..2059e1d56f7 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 @@ -4,8 +4,8 @@ "android": { "description": ".NET SDK Workload for building Android applications.", "packs": [ - "Microsoft.Android.Sdk", - "Microsoft.Android.Sdk.NET6", + "Microsoft.Android.Sdk.net7", + "Microsoft.Android.Sdk.net6", "Microsoft.Android.Ref.33", "Microsoft.Android.Runtime.33.android-arm", "Microsoft.Android.Runtime.33.android-arm64", @@ -23,7 +23,7 @@ } }, "packs": { - "Microsoft.Android.Sdk": { + "Microsoft.Android.Sdk.net7": { "kind": "sdk", "version": "@WORKLOAD_VERSION@", "alias-to": { @@ -35,7 +35,7 @@ "linux-x64": "Microsoft.Android.Sdk.Linux" } }, - "Microsoft.Android.Sdk.NET6": { + "Microsoft.Android.Sdk.net6": { "kind": "sdk", "version": "@NET6_VERSION@", "alias-to": { diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.NET.Sdk.Android/WorkloadManifest.in.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.NET.Sdk.Android/WorkloadManifest.in.targets index be847040325..6d433f1003c 100644 --- a/src/Xamarin.Android.Build.Tasks/Microsoft.NET.Sdk.Android/WorkloadManifest.in.targets +++ b/src/Xamarin.Android.Build.Tasks/Microsoft.NET.Sdk.Android/WorkloadManifest.in.targets @@ -1,8 +1,8 @@ - - 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 9a93e20bd82..6d9dd27d5c7 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 @@ -306,6 +306,7 @@ public String Say (String quote) { ExtraNuGetConfigSources = { // Projects targeting net6.0 require ref/runtime packs on NuGet.org "https://api.nuget.org/v3/index.json", + "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json", }, }; if (IsPreviewFrameworkVersion (targetFramework)) { @@ -843,6 +844,7 @@ public void DotNetPublish ([Values (false, true)] bool isRelease, [ValueSource(n ExtraNuGetConfigSources = { // Projects targeting net6.0 require ref/runtime packs on NuGet.org "https://api.nuget.org/v3/index.json", + "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json", }, }; proj.SetProperty (KnownProperties.RuntimeIdentifier, runtimeIdentifier); @@ -928,7 +930,7 @@ void CreateEmptyFile (params string [] paths) public void XamarinLegacySdk ([Values ("net6.0-android32.0", "net7.0-android33.0")] string dotnetTargetFramework) { var proj = new XASdkProject (outputType: "Library") { - Sdk = "Xamarin.Legacy.Sdk/0.2.0-alpha1", + Sdk = "Xamarin.Legacy.Sdk/0.2.0-alpha2", Sources = { new AndroidItem.AndroidLibrary ("javaclasses.jar") { BinaryContent = () => ResourceData.JavaSourceJarTestJar, @@ -937,6 +939,7 @@ public void XamarinLegacySdk ([Values ("net6.0-android32.0", "net7.0-android33.0 ExtraNuGetConfigSources = { // Projects targeting net6.0 require ref/runtime packs on NuGet.org "https://api.nuget.org/v3/index.json", + "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json", }, }; @@ -969,6 +972,7 @@ public void MauiTargetFramework (string dotnetVersion, string platform, int apiL ExtraNuGetConfigSources = { // Projects targeting net6.0 require ref/runtime packs on NuGet.org "https://api.nuget.org/v3/index.json", + "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json", }, }; diff --git a/tests/MSBuildDeviceIntegration/Tests/XASdkDeployTests.cs b/tests/MSBuildDeviceIntegration/Tests/XASdkDeployTests.cs index 4f0b3e56c06..f4826818c9e 100644 --- a/tests/MSBuildDeviceIntegration/Tests/XASdkDeployTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/XASdkDeployTests.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; @@ -74,6 +75,13 @@ public void DotNetInstallAndRun (bool isRelease, bool xamarinForms, bool? publis }; } proj.TargetFramework = targetFramework; + if (targetFramework.Contains ("net6.0")) { + proj.ExtraNuGetConfigSources = new List () { + // Projects targeting net6.0 require ref/runtime packs on NuGet.org or dotnet6 + "https://api.nuget.org/v3/index.json", + "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json", + }; + } if (publishTrimmed != null) { proj.SetProperty (KnownProperties.PublishTrimmed, publishTrimmed.ToString ()); } @@ -156,6 +164,13 @@ public void DotNetDebug ([Values("net6.0-android", "net7.0-android")] string tar var proj = new XASdkProject (); proj.TargetFramework = targetFramework; + if (targetFramework.Contains ("net6.0")) { + proj.ExtraNuGetConfigSources = new List () { + // Projects targeting net6.0 require ref/runtime packs on NuGet.org or dotnet6 + "https://api.nuget.org/v3/index.json", + "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json", + }; + } proj.SetRuntimeIdentifier (DeviceAbi); string runtimeId = proj.GetProperty (KnownProperties.RuntimeIdentifier);