Skip to content

Move AddKeepAlives trimmer step to standalone MSBuild task#10952

Draft
sbomer wants to merge 5 commits intomainfrom
dev/sbomer/addkeepalives-inner
Draft

Move AddKeepAlives trimmer step to standalone MSBuild task#10952
sbomer wants to merge 5 commits intomainfrom
dev/sbomer/addkeepalives-inner

Conversation

@sbomer
Copy link
Member

@sbomer sbomer commented Mar 16, 2026

Migrate AddKeepAlivesStep out of the ILLink custom step pipeline into a standalone MSBuild task that runs AfterTargets="ILLink", following the same pattern established by StripEmbeddedLibraries in #10894.

Core IL-rewriting logic is extracted into AddKeepAlivesHelper, shared by both the new task (trimmed builds) and the existing pipeline step (non-trimmed builds via LinkAssembliesNoShrink).

Migrate AddKeepAlivesStep out of the ILLink custom step pipeline into a
standalone MSBuild task that runs AfterTargets="ILLink", following the
same pattern established by StripEmbeddedLibraries in #10894.

Core IL-rewriting logic is extracted into AddKeepAlivesHelper, shared by
both the new task (trimmed builds) and the existing pipeline step
(non-trimmed builds via LinkAssembliesNoShrink).
@sbomer sbomer self-assigned this Mar 18, 2026
sbomer added 3 commits March 18, 2026 16:19
Replace DefaultAssemblyResolver with DirectoryAssemblyResolver (ReadWrite=true)
to avoid file handle conflicts on Windows. The directory resolver caches all
assemblies (both explicit and dependency-resolved), preventing duplicate file
opens that caused IOException when the same assembly was opened as both a
dependency and a primary target.
Replace standalone AddKeepAlives and StripEmbeddedLibraries MSBuild tasks
with a single PostTrimmingPipeline task that opens assemblies once (via
DirectoryAssemblyResolver with ReadWrite) and runs both modifications in
a single pass. Extract StripEmbeddedLibrariesStep as an
IAssemblyModifierPipelineStep for reuse.
…Step pattern

Use List<IAssemblyModifierPipelineStep> with StripEmbeddedLibrariesStep and
PostTrimmingAddKeepAlivesStep instead of calling helpers directly. Move the
IsFrameworkAssembly check into StripEmbeddedLibrariesStep.ProcessAssembly and
remove all outer-loop filtering so each step handles its own guards internally.
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