From cd8456daea4d9f32bc514a94e1a82ee63b3072bc Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Mon, 25 Jan 2021 08:53:51 -0600 Subject: [PATCH 01/10] Multi-target for .NET 6 and MonoAndroid90 Context: https://github.com/xamarin/Xamarin.Legacy.Sdk This uses Xamarin.Legacy.Sdk to multi-target. For this to work: * You have to use `dotnet build` to build any `Xamarin.Legacy.Sdk` projects. Windows can use `MSBuild.exe` from Visual Studio 16.9 Preview 4 as well. The CI build will also have to install: * .NET 6.0.100-preview.1.21103.13 * Microsoft.NET.Android.Workload 11.0.200.50 * Xamarin.Android 11.2.99.85 Other notes: * Class libraries had application properties set like `$(EnableProguard)`, `$(AndroidEnableMultiDex)`, `$(AndroidDexTool)`, `$(AndroidLinkTool)`, etc. --- Directory.Build.props | 1 + azure-pipelines.yml | 45 ++++++++++++++++--- build.cake | 22 ++++----- generated/global.json | 11 +++++ global.json | 3 +- nuget.config | 13 ++++++ source/AndroidXProject.cshtml | 21 +++------ ....appcompat-resources-typeforwarders.csproj | 4 +- ....Google.Android.Material.Extensions.csproj | 4 +- 9 files changed, 86 insertions(+), 38 deletions(-) create mode 100644 generated/global.json create mode 100644 nuget.config diff --git a/Directory.Build.props b/Directory.Build.props index ce8ff86c4..116a57352 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -4,5 +4,6 @@ git $(BUILD_SOURCEBRANCH) $(BUILD_SOURCEVERSION) + -net6preview01 diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 577a375b0..d726fc4ed 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -9,6 +9,14 @@ variables: BUILD_NUMBER: $(Build.BuildNumber) BUILD_COMMIT: $(Build.SourceVersion) PRE_RESTORE_PROJECTS: true # Windows is having an issue on CI right now + DotNetCoreVersion: 3.1.x + DotNet6Version: 6.0.100-preview.1.21103.13 + DotNet6AndroidMsi: https://dl.internalx.com/vsts-devdiv/Xamarin.Android/public/net6/4494116/master/d28ba53e1a6eff1a41e29ec50c60e3d45e6e3168/Microsoft.NET.Workload.Android.11.0.200.117.msi + DotNet6AndroidPkg: https://dl.internalx.com/vsts-devdiv/Xamarin.Android/public/net6/4494116/master/d28ba53e1a6eff1a41e29ec50c60e3d45e6e3168/Microsoft.NET.Workload.Android-11.0.200-ci.d28ba53e1a6eff1a41e29ec50c60e3d45e6e3168.117.pkg + XamarinAndroidVsix: https://dl.internalx.com/vsts-devdiv/Xamarin.Android/public/4494116/master/d28ba53e1a6eff1a41e29ec50c60e3d45e6e3168/signed/Xamarin.Android.Sdk-11.2.99.117.vsix + XamarinAndroidPkg: https://dl.internalx.com/vsts-devdiv/Xamarin.Android/public/4494116/master/d28ba53e1a6eff1a41e29ec50c60e3d45e6e3168/xamarin.android-11.2.99.117.pkg + # TODO: remove before merging + NugetSecurityAnalysisWarningLevel: warn # XAMARIN_ANDROID_PATH: resources: @@ -29,19 +37,46 @@ jobs: timeoutInMinutes: 120 validPackagePrefixes: [ 'Xamarin' ] areaPath: 'DevDiv\Xamarin SDK\Android' + dotnet: '' + initSteps: + - task: UseDotNet@2 + displayName: install .NET $(DotNetCoreVersion) + inputs: + version: $(DotNetCoreVersion) + installationPath: /usr/local/share/dotnet/ + condition: eq(variables['System.JobName'], 'macos') + - bash: > + export DOTNET_ROOT=/usr/local/share/dotnet/ && + export PATH="$DOTNET_ROOT:~/.dotnet/tools:$PATH" && + curl -L https://dot.net/v1/dotnet-install.sh > dotnet-install.sh && + sh dotnet-install.sh --version $(DotNet6Version) --install-dir $DOTNET_ROOT --verbose && + dotnet --list-sdks && + echo "##vso[task.setvariable variable=PATH]$PATH" + displayName: install .NET $(DotNet6Version) + condition: eq(variables['System.JobName'], 'macos') + - pwsh: | + $ProgressPreference = 'SilentlyContinue' + Invoke-WebRequest -Uri "https://dot.net/v1/dotnet-install.ps1" -OutFile dotnet-install.ps1 + & .\dotnet-install.ps1 -Version $(DotNet6Version) -InstallDir "$env:ProgramFiles\dotnet\" -Verbose + & dotnet --list-sdks + displayName: install .NET $(DotNet6Version) + condition: eq(variables['System.JobName'], 'windows') preBuildSteps: - pwsh: | dotnet tool uninstall --global Cake.Tool dotnet tool install --global Cake.Tool dotnet tool install --global boots - boots https://aka.ms/xamarin-android-commercial-d16-8-macos + displayName: install .NET global tools + - pwsh: | + boots $(DotNet6AndroidPkg) + boots $(XamarinAndroidPkg) condition: eq(variables['System.JobName'], 'macos') + displayName: install Xamarin.Android - pwsh: | - dotnet tool uninstall --global Cake.Tool - dotnet tool install --global Cake.Tool - dotnet tool install --global boots - boots https://aka.ms/xamarin-android-commercial-d16-8-windows + boots $(DotNet6AndroidMsi) + boots $(XamarinAndroidVsix) condition: eq(variables['System.JobName'], 'windows') + displayName: install Xamarin.Android tools: - 'xamarin.androidbinderator.tool': '0.4.2' - 'xamarin.androidx.migration.tool': '1.0.7.1' diff --git a/build.cake b/build.cake index 93331eceb..5b96841cd 100644 --- a/build.cake +++ b/build.cake @@ -604,12 +604,9 @@ Task("libs") .IsDependentOn("libs-native") .Does(() => { - var settings = new MSBuildSettings() + var settings = new DotNetCoreMSBuildSettings() .SetConfiguration(CONFIGURATION) - .SetVerbosity(VERBOSITY) .SetMaxCpuCount(0) - .EnableBinaryLogger($"./output/libs.{CONFIGURATION}.binlog") - .WithRestore() .WithProperty("MigrationPackageVersion", MIGRATION_PACKAGE_VERSION) .WithProperty("DesignTimeBuild", "false") .WithProperty("AndroidSdkBuildToolsVersion", $"{AndroidSdkBuildTools}"); @@ -617,10 +614,11 @@ Task("libs") if (!string.IsNullOrEmpty(ANDROID_HOME)) settings.WithProperty("AndroidSdkDirectory", $"{ANDROID_HOME}"); - if (!string.IsNullOrEmpty(MSBUILD_PATH)) - settings.ToolPath = MSBUILD_PATH; - - MSBuild("./generated/AndroidX.sln", settings); + DotNetCoreRestore("./generated/AndroidX.sln", new DotNetCoreRestoreSettings + { + MSBuildSettings = settings.EnableBinaryLogger("./output/restore.binlog") + }); + DotNetCoreMSBuild("./generated/AndroidX.sln", settings.EnableBinaryLogger($"./output/libs.{CONFIGURATION}.binlog")); }); Task("libs-native") @@ -642,9 +640,8 @@ Task("nuget") .IsDependentOn("libs") .Does(() => { - var settings = new MSBuildSettings() + var settings = new DotNetCoreMSBuildSettings() .SetConfiguration(CONFIGURATION) - .SetVerbosity(VERBOSITY) .SetMaxCpuCount(0) .EnableBinaryLogger($"./output/nuget.{CONFIGURATION}.binlog") .WithProperty("MigrationPackageVersion", MIGRATION_PACKAGE_VERSION) @@ -656,10 +653,7 @@ Task("nuget") if (!string.IsNullOrEmpty(ANDROID_HOME)) settings.WithProperty("AndroidSdkDirectory", $"{ANDROID_HOME}"); - if (!string.IsNullOrEmpty(MSBUILD_PATH)) - settings.ToolPath = MSBUILD_PATH; - - MSBuild("./generated/AndroidX.sln", settings); + DotNetCoreMSBuild("./generated/AndroidX.sln", settings); }); Task("samples-generate-all-targets") diff --git a/generated/global.json b/generated/global.json new file mode 100644 index 000000000..cf9f30960 --- /dev/null +++ b/generated/global.json @@ -0,0 +1,11 @@ +{ + "sdk": { + "version": "6.0.100-preview.1.21103.13", + "rollForward": "disable", + "allowPrerelease": true + }, + "msbuild-sdks": { + "Microsoft.Build.Traversal": "2.1.1", + "Xamarin.Legacy.Sdk": "0.1.0-alpha2" + } +} \ No newline at end of file diff --git a/global.json b/global.json index 384986771..2bd6d9058 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,7 @@ { "msbuild-sdks": { - "Microsoft.Build.Traversal": "2.1.1" + "Microsoft.Build.Traversal": "2.1.1", + "Xamarin.Legacy.Sdk": "0.1.0-alpha2" } } \ No newline at end of file diff --git a/nuget.config b/nuget.config new file mode 100644 index 000000000..166b7729f --- /dev/null +++ b/nuget.config @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/source/AndroidXProject.cshtml b/source/AndroidXProject.cshtml index 2b0c10e90..436c72326 100644 --- a/source/AndroidXProject.cshtml +++ b/source/AndroidXProject.cshtml @@ -1,24 +1,15 @@ @using System.Linq - + - MonoAndroid9.0 + MonoAndroid9.0;net6.0-android true @if (!string.IsNullOrEmpty(Model.AssemblyName)) { @(Model.AssemblyName) } else { @(Model.NuGetPackageId) } - Resources - Assets - False - True - Resources\Resource.designer.cs + false @(Model.NuGetPackageId.Replace("Xamarin.", "")) - true - true - true - d8 - r8 $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb From d7a82cb6c3b77138651279a1ae560719fa62aecb Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Thu, 4 Mar 2021 11:10:27 -0600 Subject: [PATCH 06/10] Fix Xamarin.AndroidX.Migration version This PR is producing: Xamarin.AndroidX.Migration.1.0.8.nupkg Xamarin.AndroidX.Migration.Tool.1.0.8.nupkg So it failed to upload to the NuGet feed. --- build.cake | 4 ++-- .../BuildTasks/Xamarin.AndroidX.Migration.BuildTasks.csproj | 1 + source/migration/Tool/Xamarin.AndroidX.Migration.Tool.csproj | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/build.cake b/build.cake index 5b96841cd..e35fae35b 100644 --- a/build.cake +++ b/build.cake @@ -925,7 +925,7 @@ Task("migration-libs") .SetMaxCpuCount(0) .EnableBinaryLogger($"./output/migration-libs.{CONFIGURATION}.binlog") .WithRestore() - .WithProperty("PackageVersion", MIGRATION_PACKAGE_VERSION); + .WithProperty("MigrationPackageVersion", MIGRATION_PACKAGE_VERSION); if (!string.IsNullOrEmpty(ANDROID_HOME)) settings.WithProperty("AndroidSdkDirectory", $"{ANDROID_HOME}"); @@ -947,7 +947,7 @@ Task("migration-nuget") .EnableBinaryLogger($"./output/migration-nuget.{CONFIGURATION}.binlog") .WithProperty("NoBuild", "true") .WithRestore() - .WithProperty("PackageVersion", MIGRATION_PACKAGE_VERSION) + .WithProperty("MigrationPackageVersion", MIGRATION_PACKAGE_VERSION) .WithProperty("MultiDexVersion", MULTIDEX_PACKAGE_VERSION) .WithProperty("PackageRequireLicenseAcceptance", "true") .WithProperty("PackageOutputPath", MakeAbsolute((DirectoryPath)"./output/").FullPath) diff --git a/source/migration/BuildTasks/Xamarin.AndroidX.Migration.BuildTasks.csproj b/source/migration/BuildTasks/Xamarin.AndroidX.Migration.BuildTasks.csproj index 8dc29e2d3..8d6e30883 100644 --- a/source/migration/BuildTasks/Xamarin.AndroidX.Migration.BuildTasks.csproj +++ b/source/migration/BuildTasks/Xamarin.AndroidX.Migration.BuildTasks.csproj @@ -4,6 +4,7 @@ netstandard2.0 latest true + $(MigrationPackageVersion)$(PackageVersionSuffix) diff --git a/source/migration/Tool/Xamarin.AndroidX.Migration.Tool.csproj b/source/migration/Tool/Xamarin.AndroidX.Migration.Tool.csproj index 8fd61038a..fd3a481c5 100644 --- a/source/migration/Tool/Xamarin.AndroidX.Migration.Tool.csproj +++ b/source/migration/Tool/Xamarin.AndroidX.Migration.Tool.csproj @@ -13,6 +13,7 @@ Migration Tools for Xamarin AndroidX 1.0.0.0 1.0.0.0 + $(MigrationPackageVersion)$(PackageVersionSuffix) This package provides a set of tools and MSBuild tasks to aid in the migration from Android Support to Android X. This package provides a set of tools and MSBuild tasks to aid in the migration from Android Support to Android X. https://go.microsoft.com/fwlink/?linkid=2099353 From 34ae555ee6a5429debc8517384afd15de87ac075 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Mon, 8 Mar 2021 10:30:49 -0600 Subject: [PATCH 07/10] Depend on .NET 6 Xamarin.Google.Guava.* Context: https://github.com/xamarin/XamarinComponents/pull/1111 --- config.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config.json b/config.json index 8ea8bc51e..b9639aea1 100644 --- a/config.json +++ b/config.json @@ -892,8 +892,8 @@ { "groupId": "com.google.guava", "artifactId": "guava", - "version": "27.1.0", - "nugetVersion": "27.1.0.4", + "version": "28.2.0", + "nugetVersion": "28.2.0-net6preview02.4534767", "nugetId": "Xamarin.Google.Guava", "dependencyOnly": true }, @@ -901,7 +901,7 @@ "groupId": "com.google.guava", "artifactId": "failureaccess", "version": "1.0.1", - "nugetVersion": "1.0.1.2", + "nugetVersion": "1.0.1.2-net6preview02.4534767", "nugetId": "Xamarin.Google.Guava.FailureAccess", "dependencyOnly": true }, @@ -909,7 +909,7 @@ "groupId": "com.google.guava", "artifactId": "listenablefuture", "version": "1.0", - "nugetVersion": "1.0.0.2", + "nugetVersion": "1.0.0.2-net6preview02.4534767", "nugetId": "Xamarin.Google.Guava.ListenableFuture", "dependencyOnly": true }, From 9ba0322934742abc55c710d3526baba8982cefa2 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Thu, 22 Apr 2021 13:24:19 -0500 Subject: [PATCH 08/10] Bump to .NET 6 Preview 3 --- azure-pipelines.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d726fc4ed..9a1c25dee 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -10,11 +10,11 @@ variables: BUILD_COMMIT: $(Build.SourceVersion) PRE_RESTORE_PROJECTS: true # Windows is having an issue on CI right now DotNetCoreVersion: 3.1.x - DotNet6Version: 6.0.100-preview.1.21103.13 - DotNet6AndroidMsi: https://dl.internalx.com/vsts-devdiv/Xamarin.Android/public/net6/4494116/master/d28ba53e1a6eff1a41e29ec50c60e3d45e6e3168/Microsoft.NET.Workload.Android.11.0.200.117.msi - DotNet6AndroidPkg: https://dl.internalx.com/vsts-devdiv/Xamarin.Android/public/net6/4494116/master/d28ba53e1a6eff1a41e29ec50c60e3d45e6e3168/Microsoft.NET.Workload.Android-11.0.200-ci.d28ba53e1a6eff1a41e29ec50c60e3d45e6e3168.117.pkg - XamarinAndroidVsix: https://dl.internalx.com/vsts-devdiv/Xamarin.Android/public/4494116/master/d28ba53e1a6eff1a41e29ec50c60e3d45e6e3168/signed/Xamarin.Android.Sdk-11.2.99.117.vsix - XamarinAndroidPkg: https://dl.internalx.com/vsts-devdiv/Xamarin.Android/public/4494116/master/d28ba53e1a6eff1a41e29ec50c60e3d45e6e3168/xamarin.android-11.2.99.117.pkg + DotNet6Version: 6.0.100-preview.3.21202.5 + DotNet6AndroidMsi: https://dl.internalx.com/vsts-devdiv/Xamarin.Android/public/net6/4624420/6.0.1xx-preview3/7d6cd1cde4182d7db2cfc5d0b55364c972b6d34f/Microsoft.NET.Workload.Android.11.0.200.196.msi + DotNet6AndroidPkg: https://dl.internalx.com/vsts-devdiv/Xamarin.Android/public/net6/4624420/6.0.1xx-preview3/7d6cd1cde4182d7db2cfc5d0b55364c972b6d34f/Microsoft.NET.Workload.Android-11.0.200-preview.3.196.pkg + XamarinAndroidVsix: https://dl.internalx.com/vsts-devdiv/Xamarin.Android/public/4624420/6.0.1xx-preview3/7d6cd1cde4182d7db2cfc5d0b55364c972b6d34f/signed/Xamarin.Android.Sdk-11.2.99.196.vsix + XamarinAndroidPkg: https://dl.internalx.com/vsts-devdiv/Xamarin.Android/public/4624420/6.0.1xx-preview3/7d6cd1cde4182d7db2cfc5d0b55364c972b6d34f/xamarin.android-11.2.99.196.pkg # TODO: remove before merging NugetSecurityAnalysisWarningLevel: warn # XAMARIN_ANDROID_PATH: From 79945fde58c27831c45fb490aec26d750b9d60d7 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Thu, 22 Apr 2021 13:26:29 -0500 Subject: [PATCH 09/10] Bump to net6preview03 NuGet version --- Directory.Build.props | 2 +- generated/global.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 8475ae34c..f8f7af7d3 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -4,7 +4,7 @@ git $(BUILD_SOURCEBRANCH) $(BUILD_SOURCEVERSION) - -net6preview02 + -net6preview03 $(PackageVersionSuffix).$(BUILD_BUILDID) diff --git a/generated/global.json b/generated/global.json index cf9f30960..dc08cc297 100644 --- a/generated/global.json +++ b/generated/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0.100-preview.1.21103.13", + "version": "6.0.100-preview.3.21202.5", "rollForward": "disable", "allowPrerelease": true }, From 9bfb0d28bc976a57aa294d28c7eb086e6ce1d315 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Fri, 23 Apr 2021 16:52:28 -0500 Subject: [PATCH 10/10] Add .NET 6 equivalent of LinkerSafe --- source/AssemblyInfo.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/source/AssemblyInfo.cs b/source/AssemblyInfo.cs index 26d808bf4..78a91d02d 100644 --- a/source/AssemblyInfo.cs +++ b/source/AssemblyInfo.cs @@ -7,3 +7,4 @@ [assembly: AssemblyMetadata ("BUILD_TIMESTAMP", "{BUILD_TIMESTAMP}")] [assembly: Android.LinkerSafe] +[assembly: AssemblyMetadata ("IsTrimmable", "True")]