Repository navigation
[Build.Tasks] Replace Dalvik collection with MSBuild items - #13387
Merged
Merged
Conversation
Preserve source paths, archive naming, metadata isolation, duplicate ordering, and APK/AAB behavior in both packaging targets. Add target-level regression coverage and expand dex packaging checks to incremental APK/AAB builds. Co-authored-by: Copilot App <[email protected]>
Remove the new target fixture and packaging test expansion as requested. Existing packaging tests do not reference the removed task and need no migration. Co-authored-by: Copilot App <[email protected]>
Keep the general MSBuild guide unchanged; the target comment explains the relevant batching constraint. Co-authored-by: Copilot App <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The existing test only checks that classes.dex exists, leaving duplicate ordering, ApkName overrides, whitespace fallback, and metadata stripping without targeted regression coverage across packaging branches and APK/AAB prefixes.
1 open issue
What changed in this PR
Replaces the Dalvik archive-item collection task with MSBuild item construction in the .NET for Android packaging pipeline, removing two custom task invocations.
Changes:
- Constructs archive items in both packaging paths, preserving ordering, duplicates,
ApkNameoverrides, and APK/AAB naming behavior. - Copies only
ArchivePathmetadata and clears temporary items after use. - Removes the task implementation and registration; custom targets invoking it directly must migrate.
| File | Description |
|---|---|
src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets |
Replaces both collection calls with item construction and removes task registration. |
src/Xamarin.Android.Build.Tasks/Tasks/CollectDalvikFilesForArchive.cs |
Deletes the superseded collection task. |
Review effort: Balanced
Comment on lines
+2049
to
+2053
| <_AndroidDalvikFiles> | ||
| <ArchivePath>$(_AndroidDalvikArchivePrefix)$([System.IO.Path]::GetFileName(`%(_AndroidDalvikFiles.Identity)`))</ArchivePath> | ||
| <ArchivePath Condition=" !$([System.String]::IsNullOrWhiteSpace(`%(_AndroidDalvikFiles.ApkName)`)) ">$(_AndroidDalvikArchivePrefix)%(_AndroidDalvikFiles.ApkName)</ArchivePath> | ||
| </_AndroidDalvikFiles> | ||
| <FilesToAddToArchive Include="@(_AndroidDalvikFiles)" KeepMetadata="ArchivePath" /> |
jonathanpeppers
approved these changes
Nov 4, 2026
simonrozsival
enabled auto-merge (squash)
November 4, 2026 09:18
simonrozsival
deleted the
simonrozsival-replace-dalvik-collection-task
branch
November 4, 2026 09:53
This was referenced Nov 4, 2026
Member
|
/backport to release/11.0.1xx |
Contributor
|
Started backporting to |
Contributor
|
@jonathanpeppers backporting to git am output$ git cherry-pick 9535641694aacb72fd8bb48fb241150af9e3416a
Auto-merging src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
CONFLICT (content): Merge conflict in src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
error: could not apply 953564169... [Build.Tasks] Replace Dalvik collection with MSBuild items (#13387)
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: [build] Replace Dalvik archive collection task with item construction
Using index info to reconstruct a base tree...
M Documentation/guides/MSBuildBestPractices.md
M src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs
M src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
Falling back to patching base and 3-way merge...
Auto-merging Documentation/guides/MSBuildBestPractices.md
CONFLICT (content): Merge conflict in Documentation/guides/MSBuildBestPractices.md
Auto-merging src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs
Auto-merging src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
CONFLICT (content): Merge conflict in src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 [build] Replace Dalvik archive collection task with item construction
Error: The process '/usr/bin/git' failed with exit code 128 |
2 of 3 tasks
jonathanpeppers
added a commit
that referenced
this pull request
Nov 20, 2026
…) (#13690) Backport of #13387. Replace the two Dalvik collection task calls with MSBuild items and remove the unused task. This avoids a custom task call for a simple item transformation. Preserve file order, duplicate inputs, `ApkName` overrides, whitespace fallback, and the case-insensitive AAB `dex/` prefix. The conflict was in the `<UsingTask>` registrations. Keep the release branch's `Xamarin.Android.Tasks.CollectAssemblyFilesToCompress` registration and remove only `CollectDalvikFilesForArchive`. All release-only packaging content stays unchanged. The release `BuildArchive` consumer reads `ArchivePath` and `JavaArchiveEntry` in the same way as main; `KeepMetadata="ArchivePath"` prevents unrelated metadata from reaching it. No multithreaded task infrastructure is included. (cherry picked from commit 9535641) Co-authored-by: Šimon Rozsíval <[email protected]> Co-authored-by: Copilot App <[email protected]>
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.

CollectDalvikFilesForArchiveonly constructs archive items from dex files. Replace its two packaging invocations with MSBuild item construction and remove the task implementation and registration, avoiding a custom task invocation for this transformation.Preserve input paths, ordering and duplicates, nonblank
ApkNameoverrides, whitespace fallback, and the case-insensitive AABdex/prefix. Update metadata on a temporary copy before appending withKeepMetadata="ArchivePath": computing metadata duringIncludegroups non-adjacent duplicates through batching, while copying all input metadata could incorrectly send dex files down the archive writer'sJavaArchiveEntrypath. Clear the temporary items after use and reset the prefix for each collection.The removed task type is no longer available to custom targets that invoke it directly.
PackageFileListBuilderremains unchanged. Existing tests and documentation are unchanged; no new tests are added.Validation:
make prepare— passed.make all— solution build completed, but local workload configuration failed with MSB4018 because extra API-level 37.1 reference assemblies were not built by this target.make leeroy— passed, including extra API levels and local workload configuration../dotnet-local.sh build src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Xamarin.Android.Build.Tests.csproj --no-restore -v:quiet— passed../dotnet-local.sh test bin/TestDebug/net10.0/Xamarin.Android.Build.Tests.dll --filter 'Name~CheckClassesDexIsIncluded' --logger 'console;verbosity=normal'— passed, 2 tests (CoreCLR and NativeAOT).git diff --check— passed.