-
Notifications
You must be signed in to change notification settings - Fork 846
Fix ILLink.Substitutions.xml not being embedded in F# assemblies #19124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Improve MSBuild integration and test coverage for IlLink tasks
Fix ILLink.Substitutions.xml not being embedded in F# assemblies
Dec 2, 2025
Contributor
✅ No release notes required |
T-Gro
reviewed
Dec 3, 2025
tests/FSharp.Build.UnitTests/GenerateILLinkSubstitutionsTests.fs
Outdated
Show resolved
Hide resolved
… test Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
… test-product relationship Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
T-Gro
reviewed
Dec 3, 2025
...me/Trimming/FSharpMetadataResource_Trimming_Test/FSharpMetadataResource_Trimming_Test.fsproj
Outdated
Show resolved
Hide resolved
Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
…ild.props Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
…argetsShim Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
T-Gro
reviewed
Dec 3, 2025
T-Gro
approved these changes
Dec 4, 2025
abonie
approved these changes
Dec 4, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The
GenerateFSharpILLinkSubstitutionsMSBuild target was usingItemName="Embed"which doesn't properly add items as embedded resources. Changed toItemName="EmbeddedResource"soILLink.Substitutions.xmlis correctly embedded in F# assemblies during compilation.This enables the ILLinker to automatically remove F# metadata resources (signature/optimization data) during trimming, reducing trimmed assembly size.
Changes:
Microsoft.FSharp.NetSdk.targets: Fix<Output TaskParameter="GeneratedItems" ItemName="Embed" />→ItemName="EmbeddedResource"FSharpMetadataResource_Trimming_Test.fsprojto use theFSharpTargetsShimproperty instead of duplicating target logic:UsingTaskandTargetblocksFSharpTargetsShimproperty to redirect to locally builtMicrosoft.FSharp.NetSdk.targetsUseLocalCompiler.Directory.Build.propsby removing redundantUsingTaskelements:FSharpEmbedResourceText,FSharpEmbedResXSource, andGenerateILLinkSubstitutionsUsingTask overridesFSharpTargetsShimalready handles all task registration via the importedMicrosoft.FSharp.TargetsfileHow FSharpTargetsShim Works:
The
FSharpTargetsShimproperty is part of the .NET SDK's F# integration. When set, the SDK imports that file instead of the bundled F# targets.Task Registration Chain:
$(FSharpTargetsShim)→Microsoft.FSharp.NetSdk.targetsMicrosoft.FSharp.NetSdk.targetsimportsMicrosoft.FSharp.TargetsMicrosoft.FSharp.Targetsregisters all F# build tasks:Fsc,Fsi,FSharpEmbedResourceText,FSharpEmbedResXSource,CreateFSharpManifestResourceName,WriteCodeFragment,FSharpPlatformInformation,SubstituteTextMicrosoft.FSharp.NetSdk.targetsalso registersMapSourceRootsandGenerateILLinkSubstitutionsSince setting
FSharpTargetsShimtriggers this chain, the individualUsingTaskoverrides inUseLocalCompiler.Directory.Build.propswere redundant and have been removed.Fixes #18591
Checklist
Test cases added
Performance benchmarks added in case of performance changes
Release notes entry updated:
Original prompt
This pull request was created as a result of the following prompt from Copilot chat.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.