[TrimmableTypeMap] Preserve trimmable typemap outputs on no-op builds#11472
Conversation
Generated trimmable typemap outputs are dynamic, so no-op builds can skip the targets that normally add them to FileWrites. Replay the prior generated outputs before IncrementalClean so they are not treated as orphaned and removed before packaging evaluates its inputs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR addresses a trimmable typemap incremental-build issue where MSBuild’s IncrementalClean could delete previously generated typemap DLLs / Java outputs on no-op builds (because skipped targets don’t re-populate @(FileWrites)). It replays the prior dynamic outputs into @(FileWrites) early in the build and strengthens the incremental test to ensure the generated typemap assemblies survive a no-op rebuild.
Changes:
- Add a
_RecordTrimmableTypeMapFileWritestarget that re-emits typemap-generated DLL/Java outputs into@(FileWrites)before_CleanGetCurrentAndPriorFileWritesruns. - Refactor typemap assembly item construction via a dedicated
@(_TrimmableTypeMapResolvedAssemblies)item list and then feed it into both@(_ResolvedAssemblies)and@(_ShrunkAssemblies). - Extend
Build_WithTrimmableTypeMap_IncrementalBuildto assert typemap DLLs from the first build still exist after a no-op second build.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/TrimmableTypeMapBuildTests.cs | Adds an assertion that typemap DLL outputs persist across a no-op rebuild where _GenerateJavaStubs is skipped. |
| src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.Trimmable.targets | Replays prior dynamic typemap outputs into @(FileWrites) before IncrementalClean and slightly restructures typemap DLL item population for packaging/native config. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/review |
|
✅ Android PR Reviewer completed successfully! |
There was a problem hiding this comment.
✅ LGTM — Clean, well-designed incremental build fix
Summary: This PR correctly solves the problem of IncrementalClean deleting dynamically-generated typemap outputs on no-op builds by replaying them into @(FileWrites) via the public $(IncrementalCleanDependsOn) hook. The approach is sound and follows MSBuild best practices.
What's good:
- The
_RecordTrimmableTypeMapFileWritestarget is well-placed viaIncrementalCleanDependsOn— the right hook for this problem - Excellent comment block explaining why the target exists
- The
_TrimmableTypeMapResolvedAssembliesrefactoring eliminates metadata duplication cleanly - Test coverage directly validates the fix scenario
Minor suggestions posted inline (2 💡):
- Redundant stamp file
FileWritesentry (already handled by_AddFilesToFileWritesglob) - Missing
Assert.IsNotEmptyguard ontypemapDllsin the test
gh is not authenticated in this environment). Please verify CI is green before merging.
Generated by Android PR Reviewer for issue #11472 · ● 13.2M
|
@copilot address review comments
|
… Assert.IsNotEmpty guard Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
Done in 01cf0d5:
|
Summary
_RecordTrimmableTypeMapFileWritestarget that re-emits the trimmable typemap's dynamic outputs (generated typemap DLLs, Java sources, copiedandroid/src/**files,acw-map.txt,AndroidManifest.xml,ApplicationRegistration.java, and the typemap assemblies list) into@(FileWrites)on no-op builds.$(IncrementalCleanDependsOn)extension point so MSBuild''sIncrementalCleansees the prior outputs and does not treat them as orphaned when_GenerateJavaStubs/_GenerateTrimmableTypeMapare skipped._GeneratedTypeMapAssembliesFromListfan-out in_AddTrimmableTypeMapAssembliesToResolvedAssembliesto populate a single_TrimmableTypeMapResolvedAssembliesitem group and include it in both_ResolvedAssembliesand_ShrunkAssemblies, keeping metadata in sync.Build_WithTrimmableTypeMap_IncrementalBuildto assert that at least one typemap DLL is produced on the first build and that every generated typemap DLL still exists after the no-op second build.Related to #10958.
Relevant sub-issues:
acw-map.txtrecorded in@(FileWrites), but does not split or merge ACW maps.Validation
./dotnet-local.sh build src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Xamarin.Android.Build.Tests.csproj -p:Configuration=Debug -v:minimalANDROID_SERIAL=emulator-5554 ./dotnet-local.sh test bin/TestDebug/net10.0/Xamarin.Android.Build.Tests.dll --filter "Name=Build_WithTrimmableTypeMap_IncrementalBuild" --logger "console;verbosity=detailed"(test run succeeded; selected cases skipped/inconclusive locally because commercial build targets are unavailable;False,NativeAOTis an unsupported configuration)