Skip to content

Skip crossgen for DotnetTools-unique assemblies to reduce SDK size#53659

Merged
MichaelSimons merged 1 commit intodotnet:mainfrom
MichaelSimons:fix/exclude-vb-from-crossgen
Apr 2, 2026
Merged

Skip crossgen for DotnetTools-unique assemblies to reduce SDK size#53659
MichaelSimons merged 1 commit intodotnet:mainfrom
MichaelSimons:fix/exclude-vb-from-crossgen

Conversation

@MichaelSimons
Copy link
Copy Markdown
Member

@MichaelSimons MichaelSimons commented Apr 1, 2026

Follow-up on #53266

Changes

FilterItemsByDuplicateHash MSBuild task (src/Tasks/sdk-tasks/FilterItemsByDuplicateHash.cs)

  • New task that compares a set of candidate files against reference files by content hash (XxHash64)
  • Returns unmatched files — those with no content-identical counterpart in the reference set
  • Shares hashing logic with DeduplicateAssembliesWithLinks via FileHasher utility class

Crossgen.targets

  • After all existing crossgen exclusions are applied, DotnetTools assemblies are compared against the rest of the layout using FilterItemsByDuplicateHash
  • Only DotnetTools assemblies that also exist outside DotnetTools are crossgen'd (these will be deduplicated afterward, so crossgen adds startup benefit without size cost)
  • Assemblies unique to DotnetTools are left as IL-only
  • Broadened the VB crossgen exclusion (Microsoft.CodeAnalysis.VisualBasic*.dll) to apply globally, not just to Roslyn/bincore

On a linux-x64 dev build, this reduces the tarball by 23.6 MB

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR broadens the crossgen exclusion for Visual Basic Roslyn assemblies so all copies across the SDK layout remain IL-only, enabling DeduplicateAssembliesWithLinks to deduplicate them via symlinks and reducing overall layout size.

Changes:

  • Removes the narrow Roslyn/bincore-only exclusion for Microsoft.CodeAnalysis.VisualBasic.dll.
  • Adds global wildcard removals for Microsoft.CodeAnalysis.VisualBasic*.dll from both RoslynFiles and RemainingFiles crossgen item groups.

DotnetTools assemblies that don't exist elsewhere in the SDK layout
gain little from crossgen since global tools are invoked infrequently.
Crossgen'ing them also prevents DeduplicateAssembliesWithLinks from
linking them to identical copies elsewhere, resulting in a net size
increase.

Add a FilterItemsByDuplicateHash MSBuild task that compares DotnetTools
assemblies against the rest of the layout by content hash. Only
assemblies that also exist outside DotnetTools are crossgen'd — these
will be deduplicated regardless, so crossgen adds startup benefit
without size cost. Assemblies unique to DotnetTools are left as IL-only.

Also broaden the existing VB crossgen exclusion to cover all
Microsoft.CodeAnalysis.VisualBasic*.dll across the entire layout,
not just the copy in Roslyn/bincore.
@MichaelSimons MichaelSimons force-pushed the fix/exclude-vb-from-crossgen branch from 70bf25a to 36a67cd Compare April 2, 2026 00:26
@MichaelSimons MichaelSimons changed the title Exclude all VB CodeAnalysis assemblies from crossgen globally Skip crossgen for DotnetTools-unique assemblies to reduce SDK size Apr 2, 2026
@MichaelSimons
Copy link
Copy Markdown
Member Author

/ba-g known intermitent failures in watch aspire and blazor web assembly tests.

@MichaelSimons MichaelSimons merged commit 4028e4a into dotnet:main Apr 2, 2026
21 of 24 checks passed
@MichaelSimons MichaelSimons deleted the fix/exclude-vb-from-crossgen branch April 2, 2026 21:12
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.

3 participants