From 5ef90a57468575783b0ce4ba18e63b89edd058b5 Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Mon, 12 Jun 2023 17:51:40 +0200 Subject: [PATCH] Use $(AndroidPackVersion) to get XA version Xamarin.Android's native runtime logs a handful of version information on application startup. This information includes XA version, up until now represented by the `$(ProductVersion)` MSBuild property. However, the property hasn't been updated for quite a while, with Xamarin.Android having switched to `$(AndroidPackVersion)` instead. Modify xaprepare to use `$(AndroidPackVersion)` instead of `$(ProductVersion)` so that we log the correct version at application startup. --- .../xaprepare/xaprepare/Application/KnownProperties.cs | 2 ++ .../xaprepare/Application/Properties.Defaults.cs.in | 2 ++ .../xaprepare/xaprepare/Steps/Step_GenerateFiles.cs | 8 +++++++- build-tools/xaprepare/xaprepare/xaprepare.targets | 2 ++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/build-tools/xaprepare/xaprepare/Application/KnownProperties.cs b/build-tools/xaprepare/xaprepare/Application/KnownProperties.cs index a4df4d587f1..90c9b049da1 100644 --- a/build-tools/xaprepare/xaprepare/Application/KnownProperties.cs +++ b/build-tools/xaprepare/xaprepare/Application/KnownProperties.cs @@ -12,6 +12,8 @@ static class KnownProperties public const string AndroidLatestStableFrameworkVersion = "AndroidLatestStableFrameworkVersion"; public const string AndroidMxeFullPath = "AndroidMxeFullPath"; public const string AndroidNdkDirectory = "AndroidNdkDirectory"; + public const string AndroidPackVersion = "AndroidPackVersion"; + public const string AndroidPackVersionSuffix = "AndroidPackVersionSuffix"; public const string AndroidSdkDirectory = "AndroidSdkDirectory"; public const string AndroidSupportedHostJitAbis = "AndroidSupportedHostJitAbis"; public const string AndroidSupportedTargetAotAbis = "AndroidSupportedTargetAotAbis"; diff --git a/build-tools/xaprepare/xaprepare/Application/Properties.Defaults.cs.in b/build-tools/xaprepare/xaprepare/Application/Properties.Defaults.cs.in index 4f461e18369..a5d49b14c5b 100644 --- a/build-tools/xaprepare/xaprepare/Application/Properties.Defaults.cs.in +++ b/build-tools/xaprepare/xaprepare/Application/Properties.Defaults.cs.in @@ -16,6 +16,8 @@ namespace Xamarin.Android.Prepare properties.Add (KnownProperties.AndroidLatestStableFrameworkVersion, StripQuotes ("@AndroidLatestStableFrameworkVersion@")); properties.Add (KnownProperties.AndroidMxeFullPath, StripQuotes (@"@AndroidMxeFullPath@")); properties.Add (KnownProperties.AndroidNdkDirectory, StripQuotes (@"@AndroidNdkDirectory@")); + properties.Add (KnownProperties.AndroidPackVersion, StripQuotes (@"@AndroidPackVersion@")); + properties.Add (KnownProperties.AndroidPackVersionSuffix, StripQuotes (@"@AndroidPackVersionSuffix@")); properties.Add (KnownProperties.AndroidSdkDirectory, StripQuotes (@"@AndroidSdkDirectory@")); properties.Add (KnownProperties.AndroidSupportedHostJitAbis, StripQuotes ("@AndroidSupportedHostJitAbis@")); properties.Add (KnownProperties.AndroidSupportedTargetAotAbis, StripQuotes ("@AndroidSupportedTargetAotAbis@")); diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs b/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs index 6fe698f44ea..c3dc48e6cb2 100644 --- a/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs +++ b/build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs @@ -165,6 +165,12 @@ GeneratedFile Get_XABuildConfig_cs (Context context) { const string OutputFileName = "XABuildConfig.cs"; + string xaVersion = context.Properties.GetRequiredValue (KnownProperties.AndroidPackVersion); + string? xaVersionSuffix = context.Properties.GetRequiredValue (KnownProperties.AndroidPackVersionSuffix); + if (!String.IsNullOrEmpty(xaVersionSuffix)) { + xaVersion = $"{xaVersion}-{xaVersionSuffix}"; + } + var replacements = new Dictionary (StringComparer.Ordinal) { { "@NDK_REVISION@", context.BuildInfo.NDKRevision }, { "@NDK_RELEASE@", BuildAndroidPlatforms.AndroidNdkVersion }, @@ -180,7 +186,7 @@ GeneratedFile Get_XABuildConfig_cs (Context context) { "@ANDROID_DEFAULT_TARGET_DOTNET_API_LEVEL@", context.Properties.GetRequiredValue (KnownProperties.AndroidDefaultTargetDotnetApiLevel) }, { "@ANDROID_LATEST_STABLE_API_LEVEL@", context.Properties.GetRequiredValue (KnownProperties.AndroidLatestStableApiLevel) }, { "@ANDROID_LATEST_UNSTABLE_API_LEVEL@", context.Properties.GetRequiredValue (KnownProperties.AndroidLatestUnstableApiLevel) }, - { "@XAMARIN_ANDROID_VERSION@", context.Properties.GetRequiredValue (KnownProperties.ProductVersion) }, + { "@XAMARIN_ANDROID_VERSION@", xaVersion }, { "@XAMARIN_ANDROID_COMMIT_HASH@", context.BuildInfo.XACommitHash }, { "@XAMARIN_ANDROID_BRANCH@", context.BuildInfo.XABranch }, }; diff --git a/build-tools/xaprepare/xaprepare/xaprepare.targets b/build-tools/xaprepare/xaprepare/xaprepare.targets index 3ba0ccfd582..81c7c742e1c 100644 --- a/build-tools/xaprepare/xaprepare/xaprepare.targets +++ b/build-tools/xaprepare/xaprepare/xaprepare.targets @@ -50,6 +50,8 @@ + +