[xabt] Add common application artifact metadata#12123
Conversation
Read common application metadata from the final merged Android manifest and preserve it on collected and published APK/AAB artifacts. Add focused coverage and documentation for manifest precedence and resource-backed labels. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8b2dfc79-737d-44c5-9fd0-d6b2b1529d82
There was a problem hiding this comment.
Pull request overview
This PR extends the @(ApplicationArtifact) contract so that Android build outputs (APK/AAB) carry authoritative, producer-owned application metadata derived from the final merged AndroidManifest.xml, ensuring correct values even when custom manifests override project properties or when GenerateApplicationManifest=false.
Changes:
- Extended
ReadAndroidManifestto expose resolved manifest values (package name,android:label,android:versionName,android:versionCode) for downstream consumption. - Stamped all
@(ApplicationArtifact)items with common application metadata (ApplicationId,ApplicationTitle/ApplicationName,ApplicationDisplayVersion,ApplicationVersion) and ensuredPublishpreserves this metadata when recreating items in$(PublishDir). - Added/updated host-side tests to validate final-manifest precedence, resource-backed labels, per-ABI artifacts, signed/unsigned outputs, and the extension hook behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets | Ensures artifact collection runs after reading the final merged manifest and stamps @(ApplicationArtifact) with common app metadata. |
| src/Xamarin.Android.Build.Tasks/Tasks/ReadAndroidManifest.cs | Adds new task outputs for manifest package/label/version values used to populate artifact metadata. |
| src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.Publish.targets | Preserves the new application metadata when Publish recreates @(ApplicationArtifact) under $(PublishDir). |
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs | Expands test coverage to validate new metadata fields, manifest precedence, publish behavior, and per-ABI artifact cases. |
| Documentation/docs-mobile/building-apps/build-targets.md | Documents that application metadata comes from the final merged manifest and that label resource references aren’t locale-resolved. |
| Documentation/docs-mobile/building-apps/build-items.md | Documents new @(ApplicationArtifact) metadata fields and clarifies precedence/resource-reference behavior. |
|
/review |
|
✅ Android PR Reviewer completed successfully! |
There was a problem hiding this comment.
🤖 Android PR Review — ⚠️ Needs a look
Clean, focused change that reads common application metadata (package, label, versionName, versionCode) from the final merged AndroidManifest.xml and stamps it onto @(ApplicationArtifact) items for both GetApplicationArtifacts and Publish. The "manifest is authoritative" design is sound — it correctly handles custom manifests and GenerateApplicationManifest=false, and keeping resource-backed labels (@string/app_name) unresolved is the right call.
Strengths
- Excellent test coverage: generated vs. custom manifest precedence,
GenerateApplicationManifest=false, resource-backed labels, signed/unsigned APK + AAB, per-ABI items, extension-hook augmentation, and Publish recreation. ReadAndroidManifestadditions reuse the existingandroidNsand null-safe navigation; nullable annotations are correct.- Documentation updates are thorough and accurately describe precedence and resource-reference behavior.
Comments (2 inline)
⚠️ PackageIdnow derives from the manifestpackageattribute rather than the always-populated$(_AndroidPackage)— a possible empty-value regression worth guarding.- 💡 The Publish metadata allowlist must stay manually in sync with
_CollectApplicationArtifacts.
Issue counts: ❌ 0 ·
CI: No pipeline checks reported yet on the head commit (status pending). Not evaluated — recheck once dotnet-android validation completes before merge.
Nice work overall.
Generated by Android PR Reviewer for #12123 · 105.7 AIC · ⌖ 13.1 AIC · ⊞ 6.8K
Comment /review to run again
Preserve the existing non-empty PackageId fallback and document the publish metadata synchronization requirement. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8b2dfc79-737d-44c5-9fd0-d6b2b1529d82
|
No code change was needed for this review trigger comment. The automated review completed successfully, and its actionable inline feedback has now been addressed. |
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Why this change is necessary
The platform SDK owns the authoritative final application artifact metadata for all Android consumers. Project properties are not sufficient because custom manifests can override them and
GenerateApplicationManifest=falsebypasses generated values entirely.This follows the
@(ApplicationArtifact)contract introduced by dotnet/android#11674 and provides the producer-owned metadata consumed by dotnet/maui#35973 without making the values MAUI-specific defaults.What changed
android:label,android:versionName, andandroid:versionCode.@(ApplicationArtifact)with:ApplicationIdApplicationTitleApplicationNameApplicationDisplayVersionApplicationVersionPackageId,PackageFormat,Signed, and per-ABIAbimetadata.Publishrecreates artifact items under$(PublishDir).GetApplicationArtifactsDependsOnoverrides effective for both direct target results and Publish recreation.@string/app_nameunchanged instead of resolving a locale.Tests
Focused host-side coverage validates generated manifests, custom manifest precedence,
GenerateApplicationManifest=false, resource-backed labels, APK/AAB signed and unsigned outputs, per-ABI items, extension overrides,GetApplicationArtifacts, and Publish recreation.Validation:
make all./dotnet-local.sh build src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Xamarin.Android.Build.Tests.csproj -c Debug -v:minimal --no-restore— 0 warnings, 0 errors./dotnet-local.sh test bin/TestDebug/net10.0/Xamarin.Android.Build.Tests.dll --filter "Name~DotNetBuildReturnsApplicationArtifacts|Name~ApplicationArtifactsUseFinalManifestMetadata" --logger "console;verbosity=minimal"— 9/9 passedgit diff --checkIssues fixed
N/A