Skip to content

[Xamarin.Android.Build.Tasks] Replace UnzipToFolder with built-in Unzip - #13505

Open
simonrozsival wants to merge 1 commit into
simonrozsival-delete-mdoc-taskfrom
simonrozsival-xml-impl-unzip-to-folder
Open

simonrozsival wants to merge 1 commit into
simonrozsival-delete-mdoc-taskfrom
simonrozsival-xml-impl-unzip-to-folder

Conversation

@simonrozsival

Copy link
Copy Markdown
Member

Context: #13490

#13490 removed Xamarin.Android.Bindings.Documentation.targets and two of the three uses of the <UnzipToFolder/> task. The only remaining use is in _CreateUniversalApkFromBundle. That target extracts universal.apk from the bundletool .apks set ($(_UniversalApkSetIntermediate)) and renames it to $(OutDir)$(_AndroidPackage)-Signed.apk through the %(DestinationFileName) metadata.

MSBuild's built-in <Unzip/> and <Copy/> tasks can do the same job, so the custom task is no longer needed:

  • <Unzip Include="universal.apk"/> extracts the entry into a new intermediate directory, $(IntermediateOutputPath)android\bin\universal-apk\. The built-in Unzip task rejects archive entries that would land outside DestinationFolder, which replaces the Files.GetArchiveExtractionPath() checks that UnzipToFolder did.
  • <Copy/> then writes the file to $(OutDir)$(_AndroidPackage)-Signed.apk.
  • SkipUnchangedFiles="false" is set on <Unzip/>. bundletool writes universal.apk with a fixed ZIP timestamp, so the default size/timestamp check could skip a changed file. For the same reason, the existing <Touch/> is kept.
  • The extracted intermediate file is added to @(FileWrites).

Delete UnzipToFolder.cs and its <UsingTask/>. The task had no tests. Files.ExtractAll() and Files.GetArchiveExtractionPath() stay, because ResolveLibraryProjectImports, ExtractJarsFromAar, and FilesTests still use them.

This PR is stacked on #13490.

Testing: Not run locally. Builds and tests were skipped for this batch to save local disk space, so CI validates the change. In particular, CI needs to confirm that AndroidPackageFormat=aab builds that also produce an APK still create -Signed.apk, and that incremental builds still behave correctly.

The last UnzipToFolder use extracted universal.apk from the universal
.apks set and renamed it to $(_AndroidPackage)-Signed.apk. Use the
built-in <Unzip/> task to extract into an intermediate directory, then
<Copy/> to the renamed destination. The built-in Unzip task rejects
entries that would escape DestinationFolder.

SkipUnchangedFiles=false is required because bundletool writes
universal.apk with a fixed ZIP timestamp.

Delete the now-unused UnzipToFolder task and its UsingTask. The
Files.ExtractAll/GetArchiveExtractionPath helpers remain in use by
ResolveLibraryProjectImports and ExtractJarsFromAar.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@simonrozsival
simonrozsival marked this pull request as ready for review November 11, 2026 14:24
Copilot AI balanced review requested due to automatic review settings November 11, 2026 14:24

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.

🟢 Approval recommended

No active review issues are reported for the MSBuild task cleanup.

No open issues 🎉

What changed in this PR

Replaces the last use of the custom UnzipToFolder task with built-in MSBuild tasks, completing cleanup after #13490 while preserving universal APK output naming.

Changes:

  • Extracts universal.apk into an intermediate directory, then copies it to the signed APK output path.
  • Forces extraction despite fixed ZIP timestamps, retains the output timestamp update, and tracks the intermediate file for cleanup.
  • Removes the unused custom task and its registration.

Local validation was not run, per the PR description.

File Description
src/​Xamarin.Android.Build.Tasks/​Xamarin.Android.Common.targets Uses built-in Unzip and Copy for universal APK extraction and removes the custom task registration.
src/​Xamarin.Android.Build.Tasks/​Tasks/​UnzipToFolder.cs Deletes the now-unused extraction task.

Review effort: Balanced

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.

2 participants