Repository navigation
[Xamarin.Android.Build.Tasks] Replace UnzipToFolder with built-in Unzip - #13505
Conversation
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]>
There was a problem hiding this comment.
🟢 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.apkinto 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
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]>
|
/review |
|
✅ Android PR Reviewer completed successfully!
|
There was a problem hiding this comment.
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" /> |
There was a problem hiding this comment.
🤖 💡 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}
Context: #13490
#13490 removed
Xamarin.Android.Bindings.Documentation.targetsand two of the three uses of the<UnzipToFolder/>task. The only remaining use is in_CreateUniversalApkFromBundle. That target extractsuniversal.apkfrom the bundletool.apksset ($(_UniversalApkSetIntermediate)) and renames it to$(OutDir)$(_AndroidPackage)-Signed.apkthrough 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-inUnziptask rejects archive entries that would land outsideDestinationFolder, which replaces theFiles.GetArchiveExtractionPath()checks thatUnzipToFolderdid.<Copy/>then writes the file to$(OutDir)$(_AndroidPackage)-Signed.apk.SkipUnchangedFiles="false"is set on<Unzip/>. bundletool writesuniversal.apkwith a fixed ZIP timestamp, so the default size/timestamp check could skip a changed file. For the same reason, the existing<Touch/>is kept.@(FileWrites).Delete
UnzipToFolder.csand its<UsingTask/>. The task had no tests.Files.ExtractAll()andFiles.GetArchiveExtractionPath()stay, becauseResolveLibraryProjectImports,ExtractJarsFromAar, andFilesTestsstill 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=aabbuilds that also produce an APK still create-Signed.apk, and that incremental builds still behave correctly.