Skip to content

[build] Replace Android tools GitInfo versioning - #12582

Open
jonathanpeppers wants to merge 2 commits into
mainfrom
jonathanpeppers-fix-androidsdk-package-version
Open

[build] Replace Android tools GitInfo versioning#12582
jonathanpeppers wants to merge 2 commits into
mainfrom
jonathanpeppers-fix-androidsdk-package-version

Conversation

@jonathanpeppers

@jonathanpeppers jonathanpeppers commented Aug 28, 2026

Copy link
Copy Markdown
Member

Summary

  • replace GitInfo-based Android tooling versions with <Android major>.<Android minor>.<commit distance>
  • use the same version for plain DLL builds and the AndroidSdk NuGet package
  • remove the GitInfo fallback files and avoid the XAVersionInfo bootstrap dependency
  • fall back to distance 0 in shallow checkouts where Git history cannot provide the real distance

Full-history builds currently produce 37.0.2346.0; shallow CI builds produce 37.0.0.0 instead of failing.

Validation

  • dotnet build src\Microsoft.Android.Build.BaseTasks\Microsoft.Android.Build.BaseTasks.csproj -c Debug
  • dotnet build src\Xamarin.Android.Tools.AndroidSdk\Xamarin.Android.Tools.AndroidSdk.csproj -c Debug
  • dotnet pack src\Xamarin.Android.Tools.AndroidSdk\Xamarin.Android.Tools.AndroidSdk.csproj -c Debug --no-build
  • built both projects from a depth-1 clone to reproduce the Azure Pipelines checkout

Version the Android tooling assemblies and AndroidSdk package as Android major.minor plus the commit distance from the current AndroidPackVersion. This keeps plain builds and package builds consistent without GitInfo or the XAVersionInfo bootstrap dependency.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 743ff1b6-4ef8-4612-aa37-5d344f02796a
Copilot AI lite review requested due to automatic review settings August 28, 2026 21:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR changes how Android tooling assemblies and the Xamarin.Android.Tools.AndroidSdk NuGet package derive their versions, moving away from XAVersionInfo/GitInfo-based versioning toward a version format based on Android major/minor plus commit distance.

Changes:

  • Removed XAVersionInfo.targets imports from the Android tooling projects and centralized version computation in Xamarin.Android.Tools.Versioning.targets.
  • Replaced GitInfo-based versioning with MSBuild Exec calls that compute PackVersionCommitCount from eng/Versions.props.
  • Deleted per-project GitInfo.txt fallback files for the affected tooling projects.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Xamarin.Android.Tools.AndroidSdk/Xamarin.Android.Tools.AndroidSdk.csproj Drops XAVersionInfo.targets import; relies on shared tooling versioning targets.
src/Xamarin.Android.Tools.AndroidSdk/GitInfo.txt Removes GitInfo fallback file for this project.
src/Microsoft.Android.Build.BaseTasks/Microsoft.Android.Build.BaseTasks.csproj Drops XAVersionInfo.targets import; relies on shared tooling versioning targets.
src/Microsoft.Android.Build.BaseTasks/GitInfo.txt Removes GitInfo fallback file for this project.
build-tools/scripts/Xamarin.Android.Tools.Versioning.targets Implements new git-based commit-distance version calculation and sets Version/PackageVersion.
Suppressed comments (1)

build-tools/scripts/Xamarin.Android.Tools.Versioning.targets:31

  • ❌ error — git blame can return a boundary revision prefixed with ^ (the previous GitCommitsInRange task explicitly mentions this case), which will make git rev-list --count $(_AndroidPackVersionCommit)..HEAD fail and break builds. Sanitize the commit hash and handle exit code 128 by falling back to 0 (matching prior behavior), while still failing for other git errors.
      <_AndroidPackVersionCommit>%(_AndroidPackVersionBlameLine.CommitHash)</_AndroidPackVersionCommit>
    </PropertyGroup>
    <Exec
        Command="git rev-list --count $(_AndroidPackVersionCommit)..HEAD"
        ConsoleToMSBuild="true"

Comment on lines +8 to +15
<Target Name="_AndroidGetToolsVersion" Condition=" '$(PackVersionCommitCount)' == '' ">
<Exec
Command="git blame -- eng/Versions.props"
ConsoleToMSBuild="true"
StandardOutputImportance="Low"
WorkingDirectory="$(XamarinAndroidSourcePath)">
<Output TaskParameter="ConsoleOutput" ItemName="_AndroidVersionBlameLines" />
</Exec>
Use a zero distance when git blame identifies the AndroidPackVersion commit as a shallow-history boundary. Full-history builds continue to calculate the real commit distance.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 743ff1b6-4ef8-4612-aa37-5d344f02796a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants