Skip to content

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

Merged
simonrozsival merged 5 commits into
mainfrom
simonrozsival-xml-impl-unzip-to-folder
Nov 13, 2026
Merged

simonrozsival merged 5 commits into
mainfrom
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.

simonrozsival and others added 4 commits November 11, 2026 13:35
The MDoc task was only invoked by the legacy BuildDocumentation target,
gated on _UseLegacyJavadocImport, which nothing sets. The containing
Xamarin.Android.Bindings.Documentation.targets is not imported anywhere.

Remove the task, its UsingTask, the BuildDocumentation target and the
MDC task-prefix doc entry.

Co-authored-by: Copilot App <[email protected]>
The `JarToXml` task and `Xamarin.Android.Bindings.JarToXml.targets`
were unreachable: the SDK only imports
`Xamarin.Android.Bindings.ClassParse.targets`, and
`Microsoft.Android.Sdk.DefaultProperties.targets` unconditionally sets
`$(AndroidClassParser)` to `class-parse`.

Remove the task, its targets file, its packaging entry, its unit-test
usages, the orphaned XA1021 resource and the `JTX` task prefix.  The
missing-SDK unit test now exercises the shared `TryGetAndroidJarPath`
helper through `GetJavaPlatformJar`.

Co-authored-by: Copilot App <[email protected]>
…tation.targets

Context: 1c14614 (#10337)
Context: b830f57 (#8464)

Nothing has imported `Xamarin.Android.Bindings.Documentation.targets` since 1c14614 deleted `Xamarin.Android.Bindings.targets`, and b830f57 had already stopped shipping it in the .NET SDK pack. Every target in it is therefore unreachable, and so is everything that only it fed:

  * The `JavaDoc` task, which was only invoked by `_GenerateJavaDocFromSourceJars`.
  * `@(JavaDocIndex)`, which was only produced by this file. It is removed from `ClassParse.targets` and `AvailableItems.targets`.
  * `@(JavaDocJar)`: `ClassParse.targets` passed `$(IntermediateOutputPath)javadocs\%(FileName)` to `<ClassParse/>`, but that directory was only ever created by `_ExtractJavaDocJars` in this file. It has been a silent no-op in .NET binding projects.
  * `$(_UseLegacyJavadocImport)`, which only selected the legacy path. Its conditions in `ClassParse.targets` and `Bindings.Core.targets` are removed.

`UnzipToFolder` remains: `Xamarin.Android.Common.targets` uses it for universal APK sets.

Co-authored-by: Copilot App <[email protected]>
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 <[email protected]>
@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

Base automatically changed from simonrozsival-delete-mdoc-task to main November 11, 2026 22:33
Built-in Unzip retains bundletool’s fixed ZIP entry timestamp. Touch the extracted intermediate as well as the signed output so CheckTimestamps and downstream timestamp-based consumers see a current file.

Co-authored-by: Copilot App <[email protected]>
@simonrozsival

Copy link
Copy Markdown
Member Author

/review

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ Android PR Reviewer completed successfully!

Generated by Android PR Reviewer for #13505

@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.

No blocking code findings; CI verification incomplete. Reviewed all 15 changed files, including the stacked binding-tool cleanup from #13490, and traced remaining task references, packaging order, cleanup registration, and existing universal-APK tests. Replacing the custom extractor with built-in Unzip plus Copy preserves the output name, forces extraction on reruns, and retains the final timestamp update needed for incremental builds.

Findings: 0 errors, 0 warnings, 1 non-blocking inline testing suggestion.

CI: All 40 checks returned for head 493a81a87aa21f0f470e9bb44db203018635e52d report success, including the aggregate dotnet-android check for Azure build 1678804. Direct Azure build/timeline verification was blocked by CLI authentication/setup errors, so I cannot independently confirm the Azure result. No local builds or tests were run for this review.

Generated by Android PR Reviewer for #13505 · copilot · gpt61 · 64.5 AIC · ⌖ 7.7 AIC · ⊞ 19.5K
Comment /review to run again

</ItemGroup>
<UnzipToFolder Sources="$(_UniversalApkSetIntermediate)" DestinationDirectories="$(OutDir)" Files="@(_FilestoExtract)" />
<!-- universal.apk has a fixed ZIP timestamp, so always overwrite instead of comparing size/timestamp. -->
<Unzip SourceFiles="$(_UniversalApkSetIntermediate)" DestinationFolder="$(_UniversalApkExtractDir)" Include="universal.apk" SkipUnchangedFiles="false" />

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.

🤖 💡 Testing — Consider adding a focused regression test that extracts two different universal.apk payloads with the same length and fixed ZIP timestamp into the same intermediate directory, then checks that the final -Signed.apk contains the second payload. UniversalApkFromBundleIsIncremental covers no-op timestamps and bundletool-argument invalidation, but does not assert updated APK contents. A content assertion would protect the overwrite behavior motivating SkipUnchangedFiles="false" during future refactoring.

{Rule: Test edge cases and specific output assertions}

@simonrozsival simonrozsival added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Nov 13, 2026
@simonrozsival
simonrozsival enabled auto-merge (squash) November 13, 2026 15:25
@simonrozsival
simonrozsival merged commit 3c99d38 into main Nov 13, 2026
40 checks passed
@simonrozsival
simonrozsival deleted the simonrozsival-xml-impl-unzip-to-folder branch November 13, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants