[build] Replace Android tools GitInfo versioning - #12582
Open
jonathanpeppers wants to merge 2 commits into
Open
Conversation
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
Contributor
There was a problem hiding this comment.
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.targetsimports from the Android tooling projects and centralized version computation inXamarin.Android.Tools.Versioning.targets. - Replaced GitInfo-based versioning with MSBuild
Execcalls that computePackVersionCommitCountfromeng/Versions.props. - Deleted per-project
GitInfo.txtfallback 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 blamecan return a boundary revision prefixed with^(the previousGitCommitsInRangetask explicitly mentions this case), which will makegit rev-list --count $(_AndroidPackVersionCommit)..HEADfail and break builds. Sanitize the commit hash and handle exit code 128 by falling back to0(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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
<Android major>.<Android minor>.<commit distance>XAVersionInfobootstrap dependency0in shallow checkouts where Git history cannot provide the real distanceFull-history builds currently produce
37.0.2346.0; shallow CI builds produce37.0.0.0instead of failing.Validation
dotnet build src\Microsoft.Android.Build.BaseTasks\Microsoft.Android.Build.BaseTasks.csproj -c Debugdotnet build src\Xamarin.Android.Tools.AndroidSdk\Xamarin.Android.Tools.AndroidSdk.csproj -c Debugdotnet pack src\Xamarin.Android.Tools.AndroidSdk\Xamarin.Android.Tools.AndroidSdk.csproj -c Debug --no-build