From 199668b0383771dbd8ce654c5e408c1eb0dafd97 Mon Sep 17 00:00:00 2001 From: Peter Collins Date: Mon, 15 Mar 2021 17:50:13 -0400 Subject: [PATCH] Rework runtime pack version declaration --- Configuration.props | 2 -- .../xaprepare/Application/Context.cs | 22 ++++++++++++++++ .../xaprepare/Application/KnownProperties.cs | 1 - .../Application/Properties.Defaults.cs.in | 1 - .../xaprepare/ConfigAndData/Configurables.cs | 23 ----------------- .../xaprepare/Steps/Step_GenerateFiles.cs | 20 ++++++++++++--- .../Steps/Step_InstallDotNetPreview.cs | 15 +++++++---- .../xaprepare/xaprepare/package-download.proj | 25 +++++++++++++++++++ .../xaprepare/xaprepare/xaprepare.csproj | 7 +----- .../xaprepare/xaprepare/xaprepare.targets | 1 - eng/Version.Details.xml | 12 +++------ eng/Versions.props | 9 ++++--- 12 files changed, 84 insertions(+), 54 deletions(-) create mode 100644 build-tools/xaprepare/xaprepare/package-download.proj diff --git a/Configuration.props b/Configuration.props index 1470cd60e0f..5b02f0a4572 100644 --- a/Configuration.props +++ b/Configuration.props @@ -75,8 +75,6 @@ $(AndroidToolchainDirectory)\ndk $(AndroidToolchainDirectory)\dotnet\ $(DotNetPreviewPath)dotnet - - 6.0.100 $(AndroidToolchainDirectory)\wix\ 3.18.1 7c386a739f915f5bd60051f2572c24782388e807. diff --git a/build-tools/xaprepare/xaprepare/Application/Context.cs b/build-tools/xaprepare/xaprepare/Application/Context.cs index bba12474a40..55a9de706e3 100644 --- a/build-tools/xaprepare/xaprepare/Application/Context.cs +++ b/build-tools/xaprepare/xaprepare/Application/Context.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Xml.Linq; namespace Xamarin.Android.Prepare { @@ -358,6 +359,27 @@ partial class Context : AppObject } } + string _bundledPreviewRuntimePackVersion; + public string BundledPreviewRuntimePackVersion { + get { + if (string.IsNullOrEmpty (_bundledPreviewRuntimePackVersion)) { + var dotnetPath = Properties.GetRequiredValue (KnownProperties.DotNetPreviewPath); + dotnetPath = dotnetPath.TrimEnd (new char [] { Path.DirectorySeparatorChar }); + var dotnetPreviewVersion = Properties.GetRequiredValue (KnownProperties.MicrosoftDotnetSdkInternalPackageVersion); + var bundledVersionsPath = Path.Combine (dotnetPath, "sdk", dotnetPreviewVersion, "Microsoft.NETCoreSdk.BundledVersions.props"); + if (!File.Exists (bundledVersionsPath)) + throw new FileNotFoundException ("Could not find Microsoft.NETCoreSdk.BundledVersions.props.", bundledVersionsPath); + + var version = XDocument.Load (bundledVersionsPath).Descendants ().FirstOrDefault (p => p.Name == "BundledNETCoreAppPackageVersion")?.Value ?? string.Empty; + if (string.IsNullOrEmpty (version)) + throw new InvalidOperationException ($"Unable to locate $(BundledNETCoreAppPackageVersion) in {bundledVersionsPath}."); + + _bundledPreviewRuntimePackVersion = version; + } + return _bundledPreviewRuntimePackVersion; + } + } + /// /// Do not install mingw-w64 with brew on MacOS, default false /// diff --git a/build-tools/xaprepare/xaprepare/Application/KnownProperties.cs b/build-tools/xaprepare/xaprepare/Application/KnownProperties.cs index edc842980c1..faf02359ca6 100644 --- a/build-tools/xaprepare/xaprepare/Application/KnownProperties.cs +++ b/build-tools/xaprepare/xaprepare/Application/KnownProperties.cs @@ -22,7 +22,6 @@ static class KnownProperties public const string CommandLineToolsFolder = nameof (CommandLineToolsFolder); public const string DotNetPreviewPath = "DotNetPreviewPath"; public const string MicrosoftDotnetSdkInternalPackageVersion = "MicrosoftDotnetSdkInternalPackageVersion"; - public const string MicrosoftNetCoreAppRuntimeandroidarm64PackageVersion = "MicrosoftNetCoreAppRuntimeandroidarm64PackageVersion"; public const string EmulatorVersion = "EmulatorVersion"; public const string EmulatorPkgRevision = "EmulatorPkgRevision"; public const string HostOS = "HostOS"; diff --git a/build-tools/xaprepare/xaprepare/Application/Properties.Defaults.cs.in b/build-tools/xaprepare/xaprepare/Application/Properties.Defaults.cs.in index cbaf59c1eb1..d68d17f48a0 100644 --- a/build-tools/xaprepare/xaprepare/Application/Properties.Defaults.cs.in +++ b/build-tools/xaprepare/xaprepare/Application/Properties.Defaults.cs.in @@ -26,7 +26,6 @@ namespace Xamarin.Android.Prepare properties.Add (KnownProperties.CommandLineToolsVersion, StripQuotes ("@CommandLineToolsVersion@")); properties.Add (KnownProperties.DotNetPreviewPath, StripQuotes (@"@DotNetPreviewPath@")); properties.Add (KnownProperties.MicrosoftDotnetSdkInternalPackageVersion, StripQuotes ("@MicrosoftDotnetSdkInternalPackageVersion@")); - properties.Add (KnownProperties.MicrosoftNetCoreAppRuntimeandroidarm64PackageVersion, StripQuotes ("@MicrosoftNetCoreAppRuntimeandroidarm64PackageVersion@")); properties.Add (KnownProperties.EmulatorVersion, StripQuotes ("@EmulatorVersion@")); properties.Add (KnownProperties.EmulatorPkgRevision, StripQuotes ("@EmulatorPkgRevision@")); properties.Add (KnownProperties.HostOS, StripQuotes ("@HostOS@")); diff --git a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs index 7a2681272d6..d32ec9411d0 100644 --- a/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs +++ b/build-tools/xaprepare/xaprepare/ConfigAndData/Configurables.cs @@ -367,12 +367,6 @@ public static partial class Paths public static string MonoArchiveLocalPath => Path.Combine (ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainCacheDirectory), MonoArchiveFileName); public static string MonoArchiveWindowsLocalPath => Path.Combine (ctx.Properties.GetRequiredValue (KnownProperties.AndroidToolchainCacheDirectory), MonoArchiveWindowsFileName); - // .NET 6 - public static string NetcoreAppRuntimeAndroidARM => GetCachedPath (ref netcoreAppRuntimeAndroidARM, () => GetNetcoreAppRuntimePath (ctx, "arm")); - public static string NetcoreAppRuntimeAndroidARM64 => GetCachedPath (ref netcoreAppRuntimeAndroidARM64, () => GetNetcoreAppRuntimePath (ctx, "arm64")); - public static string NetcoreAppRuntimeAndroidX86 => GetCachedPath (ref netcoreAppRuntimeAndroidX86, () => GetNetcoreAppRuntimePath (ctx, "x86")); - public static string NetcoreAppRuntimeAndroidX86_64 => GetCachedPath (ref netcoreAppRuntimeAndroidX86_64, () => GetNetcoreAppRuntimePath (ctx, "x64")); - // CMake public static string CmakeMSBuildPropsName = "cmake-config.props"; public static string CmakeShellScriptsPropsName = "cmake-config.sh"; @@ -398,17 +392,6 @@ public static partial class Paths return Directory.Exists (path) ? path : Path.Combine (MonoSdksTpnExternalPath, "llvm"); }); - static string GetNetcoreAppRuntimePath (Context ctx, string androidTarget) - { - return Path.Combine ( - XAPackagesDir, - $"microsoft.netcore.app.runtime.android-{androidTarget}", - ctx.Properties.GetRequiredValue (KnownProperties.MicrosoftNetCoreAppRuntimeandroidarm64PackageVersion), - "runtimes", - $"android-{androidTarget}" - ); - } - static string DetermineNugetPackagesDir (Context ctx) { return Path.GetFullPath ( @@ -466,8 +449,6 @@ static string GetCachedPath (ref string? variable, Func creator) static string? mingw64CmakeTemplatePath; static string? monoRuntimesEnabledAbisCachePath; static string? frameworkListInstallPath; - static string? correttoCacheDir; - static string? correttoInstallDir; static string? profileAssembliesProjitemsPath; static string? bclTestsSourceDir; static string? installHostBCLDir; @@ -487,10 +468,6 @@ static string GetCachedPath (ref string? variable, Func creator) static string? configurationPropsGeneratedPath; static string? windowsBinutilsInstallDir; static string? hostBinutilsInstallDir; - static string? netcoreAppRuntimeAndroidARM; - static string? netcoreAppRuntimeAndroidARM64; - static string? netcoreAppRuntimeAndroidX86; - static string? netcoreAppRuntimeAndroidX86_64; static string? monodroidSourceDir; } } diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs b/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs index 97a9a524c5a..d0653ab2891 100644 --- a/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs +++ b/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs @@ -87,11 +87,12 @@ GeneratedFile Get_Cmake_XA_Build_Configuration (Context context) { const string OutputFileName = "xa_build_configuration.cmake"; + var runtimePackVersion = context.BundledPreviewRuntimePackVersion; var replacements = new Dictionary (StringComparer.Ordinal) { - { "@NETCORE_APP_RUNTIME_ANDROID_ARM@", Utilities.EscapePathSeparators (Configurables.Paths.NetcoreAppRuntimeAndroidARM) }, - { "@NETCORE_APP_RUNTIME_ANDROID_ARM64@", Utilities.EscapePathSeparators (Configurables.Paths.NetcoreAppRuntimeAndroidARM64) }, - { "@NETCORE_APP_RUNTIME_ANDROID_X86@", Utilities.EscapePathSeparators (Configurables.Paths.NetcoreAppRuntimeAndroidX86) }, - { "@NETCORE_APP_RUNTIME_ANDROID_X86_64@", Utilities.EscapePathSeparators (Configurables.Paths.NetcoreAppRuntimeAndroidX86_64) }, + { "@NETCORE_APP_RUNTIME_ANDROID_ARM@", Utilities.EscapePathSeparators (GetNetCoreAppRuntimePath ("arm", runtimePackVersion)) }, + { "@NETCORE_APP_RUNTIME_ANDROID_ARM64@", Utilities.EscapePathSeparators (GetNetCoreAppRuntimePath ("arm64", runtimePackVersion)) }, + { "@NETCORE_APP_RUNTIME_ANDROID_X86@", Utilities.EscapePathSeparators (GetNetCoreAppRuntimePath ("x86", runtimePackVersion)) }, + { "@NETCORE_APP_RUNTIME_ANDROID_X86_64@", Utilities.EscapePathSeparators (GetNetCoreAppRuntimePath ("x86_64", runtimePackVersion)) }, }; return new GeneratedPlaceholdersFile ( @@ -99,6 +100,17 @@ GeneratedFile Get_Cmake_XA_Build_Configuration (Context context) Path.Combine (Configurables.Paths.BuildToolsScriptsDir, $"{OutputFileName}.in"), Path.Combine (Configurables.Paths.BuildBinDir, OutputFileName) ); + + string GetNetCoreAppRuntimePath (string androidTarget, string version) + { + return Path.Combine ( + Configurables.Paths.XAPackagesDir, + $"microsoft.netcore.app.runtime.android-{androidTarget}", + version, + "runtimes", + $"android-{androidTarget}" + ); + } } GeneratedFile Get_Configuration_Generated_Props (Context context) diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs b/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs index 35299bfa314..a6f6bb0e21e 100644 --- a/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs +++ b/build-tools/xaprepare/xaprepare/Steps/Step_InstallDotNetPreview.cs @@ -17,6 +17,7 @@ protected override async Task Execute (Context context) { var dotnetPath = context.Properties.GetRequiredValue (KnownProperties.DotNetPreviewPath); dotnetPath = dotnetPath.TrimEnd (new char [] { Path.DirectorySeparatorChar }); + var dotnetTool = Path.Combine (dotnetPath, "dotnet"); var dotnetPreviewVersion = context.Properties.GetRequiredValue (KnownProperties.MicrosoftDotnetSdkInternalPackageVersion); var dotnetTestRuntimeVersion = Configurables.Defaults.DotNetTestRuntimeVersion; @@ -38,8 +39,8 @@ protected override async Task Execute (Context context) } } - if (Directory.Exists (dotnetPath)) { - if (!TestDotNetSdk (dotnetPath)) { + if (File.Exists (dotnetTool)) { + if (!TestDotNetSdk (dotnetTool)) { Log.WarningLine ($"Attempt to run `dotnet --version` failed, reinstalling the SDK."); Utilities.DeleteDirectory (dotnetPath); } @@ -55,7 +56,11 @@ protected override async Task Execute (Context context) return false; } - return true; + // Install runtime packs associated with the SDK previously installed. + var packageDownloadProj = Path.Combine (BuildPaths.XamarinAndroidSourceRoot, "build-tools", "xaprepare", "xaprepare", "package-download.proj"); + var logPath = Path.Combine (Configurables.Paths.BuildBinDir, $"msbuild-{context.BuildTimeStamp}-download-runtime-packs.binlog"); + return Utilities.RunCommand (dotnetTool, new string [] { "restore", $"-p:DotNetRuntimePacksVersion={context.BundledPreviewRuntimePackVersion}", + ProcessRunner.QuoteArgument (packageDownloadProj), ProcessRunner.QuoteArgument ($"-bl:{logPath}") }); } async Task InstallDotNetAsync (Context context, string dotnetPath, string version, bool runtimeOnly = false) @@ -122,9 +127,9 @@ async Task InstallDotNetAsync (Context context, string dotnetPath, string } } - bool TestDotNetSdk (string dotnetPath) + bool TestDotNetSdk (string dotnetTool) { - return Utilities.RunCommand (Path.Combine (dotnetPath, "dotnet"), new string [] { "--version" }); + return Utilities.RunCommand (dotnetTool, new string [] { "--version" }); } } diff --git a/build-tools/xaprepare/xaprepare/package-download.proj b/build-tools/xaprepare/xaprepare/package-download.proj new file mode 100644 index 00000000000..3966ae5daff --- /dev/null +++ b/build-tools/xaprepare/xaprepare/package-download.proj @@ -0,0 +1,25 @@ + + + + + netstandard2.0 + $(BundledNETCoreAppPackageVersion) + + + + + + + + + + diff --git a/build-tools/xaprepare/xaprepare/xaprepare.csproj b/build-tools/xaprepare/xaprepare/xaprepare.csproj index d3e074ae97b..e66b5cc2c32 100644 --- a/build-tools/xaprepare/xaprepare/xaprepare.csproj +++ b/build-tools/xaprepare/xaprepare/xaprepare.csproj @@ -60,10 +60,5 @@ - - - - - - + diff --git a/build-tools/xaprepare/xaprepare/xaprepare.targets b/build-tools/xaprepare/xaprepare/xaprepare.targets index c635ca7e5a3..c1677163752 100644 --- a/build-tools/xaprepare/xaprepare/xaprepare.targets +++ b/build-tools/xaprepare/xaprepare/xaprepare.targets @@ -60,7 +60,6 @@ - diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index e3c556db533..c931cdfaa3e 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -1,16 +1,12 @@ - + https://github.com/dotnet/installer - a28ceebdcd4601c69f86d4ec1341ad95295f5020 + 18a633b84588c419939a55ee9504727eeb2e9714 - - https://github.com/dotnet/runtime - b38ea6a4f067b571a007b2ac69f3e4431cb100e7 - - + https://github.com/mono/linker - bb923d296a0aa9afa499ffe29dcf71e66ee54352 + 75b1c3003bc12139c3a918705da5a4c12e7cb37b diff --git a/eng/Versions.props b/eng/Versions.props index 4b8c9d0f1f8..a5028e50d79 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -1,8 +1,11 @@ - 6.0.100-preview.3.21160.15 - 6.0.0-preview.3.21160.15 - 6.0.100-preview.2.21160.1 + 6.0.100-preview.3.21167.10 + 6.0.100-preview.2.21167.4 + + + + $([System.Text.RegularExpressions.Regex]::Replace($(MicrosoftDotnetSdkInternalPackageVersion), `[-+].*$`, ""))