Skip to content

[xabt] Add common application artifact metadata#12123

Merged
jonathanpeppers merged 2 commits into
mainfrom
redth-android-artifact-metadata
Jul 17, 2026
Merged

[xabt] Add common application artifact metadata#12123
jonathanpeppers merged 2 commits into
mainfrom
redth-android-artifact-metadata

Conversation

@Redth

@Redth Redth commented Jul 15, 2026

Copy link
Copy Markdown
Member
  • Useful description of why the change is necessary.
  • Links to issues fixed or prerequisite work.
  • Unit tests.

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=false bypasses 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

  • Extended the existing final merged-manifest read path to expose the resolved package, application android:label, android:versionName, and android:versionCode.
  • Stamped every APK/AAB @(ApplicationArtifact) with:
    • ApplicationId
    • ApplicationTitle
    • ApplicationName
    • ApplicationDisplayVersion
    • ApplicationVersion
  • Preserved PackageId, PackageFormat, Signed, and per-ABI Abi metadata.
  • Preserved all producer-owned common and Android metadata when Publish recreates artifact items under $(PublishDir).
  • Kept GetApplicationArtifactsDependsOn overrides effective for both direct target results and Publish recreation.
  • Kept resource-backed labels such as @string/app_name unchanged instead of resolving a locale.
  • Documented final merged-manifest precedence and resource-reference behavior.

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.

Passed: 9
Failed: 0
Skipped: 0
Duration: 40 s

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 passed
  • git diff --check

Issues fixed

N/A

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
Copilot AI review requested due to automatic review settings July 15, 2026 16:32

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 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 ReadAndroidManifest to 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 ensured Publish preserves 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.

@jonathanpeppers

Copy link
Copy Markdown
Member

/review

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Android PR Reviewer completed successfully!

@github-actions github-actions Bot 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.

🤖 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.
  • ReadAndroidManifest additions reuse the existing androidNs and null-safe navigation; nullable annotations are correct.
  • Documentation updates are thorough and accurately describe precedence and resource-reference behavior.

Comments (2 inline)

  • ⚠️ PackageId now derives from the manifest package attribute 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 · ⚠️ 1 · 💡 1

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

Comment thread src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets Outdated
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
@Redth

Redth commented Jul 15, 2026

Copy link
Copy Markdown
Member Author

No code change was needed for this review trigger comment. The automated review completed successfully, and its actionable inline feedback has now been addressed.

@Redth

Redth commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@jonathanpeppers
jonathanpeppers merged commit b7b7a55 into main Jul 17, 2026
44 checks passed
@jonathanpeppers
jonathanpeppers deleted the redth-android-artifact-metadata branch July 17, 2026 13:43
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.

3 participants