Skip to content

[Xamarin.Android.Build.Tasks] Replace CreateResgenManifest with WriteLinesToFile - #13496

Open
simonrozsival wants to merge 4 commits into
mainfrom
simonrozsival-xml-impl-createresgenmanifest
Open

simonrozsival wants to merge 4 commits into
mainfrom
simonrozsival-xml-impl-createresgenmanifest

Conversation

@simonrozsival

Copy link
Copy Markdown
Member

Context: #13483
Context: #13486

The _PrepareUpdateAndroidResgen target used the CreateResgenManifest task for one job: writing a placeholder AndroidManifest.xml into a fresh temporary directory, which <Aapt2Link/> uses as ManifestFiles. The file is a two-line constant apart from the package name, so a custom task isn't needed.

This change puts the manifest in a private __ResgenManifest property, written as a CDATA block so it reads as plain XML, and writes it with the built-in <WriteLinesToFile Overwrite="true"/>. $(_AndroidPackage) is inserted without XML escaping because <GetAndroidPackageName/> has already validated it. WriteOnlyWhenDifferent isn't used because the target directory is always newly created.

It removes the task, its <UsingTask/>, and the CRM prefix in Documentation/docs-mobile/messages/index.md. The task had no unit tests and no XA codes.

Output differences:

  • The file no longer begins with a UTF-8 BOM.
  • Line endings follow Environment.NewLine instead of XDocument's default.

#13483 (CreateTemporaryDirectory → <MakeDir/>) and #13486 (GetExtraPackages → <XmlPeek/>) edit lines next to this change, so whichever merges second will have a trivial textual conflict.

Testing: no local build or test run, to save disk space; this relies on CI. xmllint --noout confirms Xamarin.Android.Common.targets is still well-formed.

simonrozsival and others added 2 commits November 11, 2026 13:36
…LinesToFile

The `_PrepareUpdateAndroidResgen` target used the `CreateResgenManifest`
task only to write a minimal `AndroidManifest.xml` for aapt2 into a
freshly created temporary directory. Write the same two lines with the
built-in `<WriteLinesToFile/>` task instead and remove the task, its
`<UsingTask/>`, and its `CRM` docs prefix entry.

The package name comes from `GetAndroidPackageName`, which already
validates it, so it does not need XML escaping. `?` is written as `%3F`
to avoid any wildcard interpretation of the item spec.

Differences: the file no longer has a UTF-8 BOM, and line endings follow
`Environment.NewLine`.

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

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 11, 2026 13:25

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.

🟡 Changes recommended

The new private MSBuild property __ResgenManifest violates the _Android naming convention and needs renaming to _AndroidResgenManifest, including its Lines reference.

1 open issue
What changed in this PR

Simplifies .NET for Android resource generation by replacing a dedicated manifest-writing task with MSBuild’s built-in WriteLinesToFile.

Changes:

  • Defines the placeholder manifest in a CDATA property and writes it into the temporary resource-generation directory.
  • Removes CreateResgenManifest, its task registration, and its documented diagnostic prefix.
File Description
src/​Xamarin.Android.Build.Tasks/​Xamarin.Android.Common.targets Replaces the custom task with inline manifest content and WriteLinesToFile.
src/​Xamarin.Android.Build.Tasks/​Tasks/​CreateResgenManifest.cs Deletes the obsolete manifest-writing task.
Documentation/​docs-mobile/​messages/​index.md Removes the retired CRM task prefix.

Review effort: Balanced

simonrozsival and others added 2 commits November 11, 2026 17:18
$(_AndroidPackage) was interpolated directly into the manifest XML,
so a package name containing XML metacharacters would produce invalid
(or injected) XML. Write a static template and use <XmlPoke/> to set
/manifest/@Package so the value is properly escaped.

Also rename __ResgenManifest to _AndroidResgenManifest.

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

Escape the XmlPoke value for MSBuild item-list parsing so semicolons remain part of the package attribute.

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

This branch has not been deployed

No deployments
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