Skip to content

Commit 5ef90a5

Browse files
committed
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.
1 parent 4125c0c commit 5ef90a5

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

build-tools/xaprepare/xaprepare/Application/KnownProperties.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ static class KnownProperties
1212
public const string AndroidLatestStableFrameworkVersion = "AndroidLatestStableFrameworkVersion";
1313
public const string AndroidMxeFullPath = "AndroidMxeFullPath";
1414
public const string AndroidNdkDirectory = "AndroidNdkDirectory";
15+
public const string AndroidPackVersion = "AndroidPackVersion";
16+
public const string AndroidPackVersionSuffix = "AndroidPackVersionSuffix";
1517
public const string AndroidSdkDirectory = "AndroidSdkDirectory";
1618
public const string AndroidSupportedHostJitAbis = "AndroidSupportedHostJitAbis";
1719
public const string AndroidSupportedTargetAotAbis = "AndroidSupportedTargetAotAbis";

build-tools/xaprepare/xaprepare/Application/Properties.Defaults.cs.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ namespace Xamarin.Android.Prepare
1616
properties.Add (KnownProperties.AndroidLatestStableFrameworkVersion, StripQuotes ("@AndroidLatestStableFrameworkVersion@"));
1717
properties.Add (KnownProperties.AndroidMxeFullPath, StripQuotes (@"@AndroidMxeFullPath@"));
1818
properties.Add (KnownProperties.AndroidNdkDirectory, StripQuotes (@"@AndroidNdkDirectory@"));
19+
properties.Add (KnownProperties.AndroidPackVersion, StripQuotes (@"@AndroidPackVersion@"));
20+
properties.Add (KnownProperties.AndroidPackVersionSuffix, StripQuotes (@"@AndroidPackVersionSuffix@"));
1921
properties.Add (KnownProperties.AndroidSdkDirectory, StripQuotes (@"@AndroidSdkDirectory@"));
2022
properties.Add (KnownProperties.AndroidSupportedHostJitAbis, StripQuotes ("@AndroidSupportedHostJitAbis@"));
2123
properties.Add (KnownProperties.AndroidSupportedTargetAotAbis, StripQuotes ("@AndroidSupportedTargetAotAbis@"));

build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ GeneratedFile Get_XABuildConfig_cs (Context context)
165165
{
166166
const string OutputFileName = "XABuildConfig.cs";
167167

168+
string xaVersion = context.Properties.GetRequiredValue (KnownProperties.AndroidPackVersion);
169+
string? xaVersionSuffix = context.Properties.GetRequiredValue (KnownProperties.AndroidPackVersionSuffix);
170+
if (!String.IsNullOrEmpty(xaVersionSuffix)) {
171+
xaVersion = $"{xaVersion}-{xaVersionSuffix}";
172+
}
173+
168174
var replacements = new Dictionary<string, string> (StringComparer.Ordinal) {
169175
{ "@NDK_REVISION@", context.BuildInfo.NDKRevision },
170176
{ "@NDK_RELEASE@", BuildAndroidPlatforms.AndroidNdkVersion },
@@ -180,7 +186,7 @@ GeneratedFile Get_XABuildConfig_cs (Context context)
180186
{ "@ANDROID_DEFAULT_TARGET_DOTNET_API_LEVEL@", context.Properties.GetRequiredValue (KnownProperties.AndroidDefaultTargetDotnetApiLevel) },
181187
{ "@ANDROID_LATEST_STABLE_API_LEVEL@", context.Properties.GetRequiredValue (KnownProperties.AndroidLatestStableApiLevel) },
182188
{ "@ANDROID_LATEST_UNSTABLE_API_LEVEL@", context.Properties.GetRequiredValue (KnownProperties.AndroidLatestUnstableApiLevel) },
183-
{ "@XAMARIN_ANDROID_VERSION@", context.Properties.GetRequiredValue (KnownProperties.ProductVersion) },
189+
{ "@XAMARIN_ANDROID_VERSION@", xaVersion },
184190
{ "@XAMARIN_ANDROID_COMMIT_HASH@", context.BuildInfo.XACommitHash },
185191
{ "@XAMARIN_ANDROID_BRANCH@", context.BuildInfo.XABranch },
186192
};

build-tools/xaprepare/xaprepare/xaprepare.targets

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
<Replacement Include="@AndroidMxeFullPath@=$(AndroidMxeFullPath)" />
5151
<Replacement Include="@AndroidNdkDirectory@=$(AndroidNdkDirectory)" />
5252
<Replacement Include="@AndroidNdkVersion@=$(AndroidNdkVersion)" />
53+
<Replacement Include="@AndroidPackVersion@=$(AndroidPackVersion)" />
54+
<Replacement Include="@AndroidPackVersionSuffix@=$(AndroidPackVersionSuffix)" />
5355
<Replacement Include="@AndroidSdkDirectory@=$(AndroidSdkDirectory)" />
5456
<Replacement Include="@AndroidSupportedHostJitAbis@=$(AndroidSupportedHostJitAbis)" />
5557
<Replacement Include="@AndroidSupportedTargetAotAbis@=$(AndroidSupportedTargetAotAbis)" />

0 commit comments

Comments
 (0)