Repository navigation
[Xamarin.Android.Build.Tasks] Replace CreateResgenManifest with WriteLinesToFile - #13496
Open
simonrozsival wants to merge 4 commits into
Open
simonrozsival wants to merge 4 commits into
simonrozsival wants to merge 4 commits into
Conversation
…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>
Contributor
There was a problem hiding this comment.
🟡 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
$(_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
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.

Context: #13483
Context: #13486
The
_PrepareUpdateAndroidResgentarget used theCreateResgenManifesttask for one job: writing a placeholderAndroidManifest.xmlinto a fresh temporary directory, which<Aapt2Link/>uses asManifestFiles. 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
__ResgenManifestproperty, 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.WriteOnlyWhenDifferentisn't used because the target directory is always newly created.It removes the task, its
<UsingTask/>, and theCRMprefix inDocumentation/docs-mobile/messages/index.md. The task had no unit tests and noXAcodes.Output differences:
Environment.NewLineinstead 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 --nooutconfirmsXamarin.Android.Common.targetsis still well-formed.