Skip to content

Commit

Permalink
Use $(AndroidPackVersion) to get XA version
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
grendello committed Jun 12, 2023
1 parent 4125c0c commit 5ef90a5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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@"));
Expand Down
8 changes: 7 additions & 1 deletion build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string> (StringComparer.Ordinal) {
{ "@NDK_REVISION@", context.BuildInfo.NDKRevision },
{ "@NDK_RELEASE@", BuildAndroidPlatforms.AndroidNdkVersion },
Expand All @@ -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 },
};
Expand Down
2 changes: 2 additions & 0 deletions build-tools/xaprepare/xaprepare/xaprepare.targets
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
<Replacement Include="@AndroidMxeFullPath@=$(AndroidMxeFullPath)" />
<Replacement Include="@AndroidNdkDirectory@=$(AndroidNdkDirectory)" />
<Replacement Include="@AndroidNdkVersion@=$(AndroidNdkVersion)" />
<Replacement Include="@AndroidPackVersion@=$(AndroidPackVersion)" />
<Replacement Include="@AndroidPackVersionSuffix@=$(AndroidPackVersionSuffix)" />
<Replacement Include="@AndroidSdkDirectory@=$(AndroidSdkDirectory)" />
<Replacement Include="@AndroidSupportedHostJitAbis@=$(AndroidSupportedHostJitAbis)" />
<Replacement Include="@AndroidSupportedTargetAotAbis@=$(AndroidSupportedTargetAotAbis)" />
Expand Down

0 comments on commit 5ef90a5

Please sign in to comment.