-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add more options to control trimming behavior #6380
Comments
Some more comments from @marek-safar on the other thread:
We could do it via a property by supporting, say, semicolon-delimited assembly names and parsing the property into an ItemGroup - but I'm not sure that's best MSBuild practice. I think making it an ItemGroup would be the best choice, even though it doesn't let you set it on the command-line, to my knowledge. @rainersigwald do you have any advice on representing a per-assembly option in MSBuild? |
This includes some background on what we added for .NET5, and a proposal for more options in .NET6 : - An assembly-level attribute to opt into trimming - Simplified trimming opt-in from the SDK - Simplified "trim all assemblies" flag This is a summary of the discussion in dotnet#1269 and https://github.com/dotnet/sdk/issues/14642, and the .NET 5 discussion in dotnet/sdk#12035.
* Add design doc for trimming opt-in/opt-out This includes some background on what we added for .NET5, and a proposal for more options in .NET6 : - An assembly-level attribute to opt into trimming - Simplified trimming opt-in from the SDK - Simplified "trim all assemblies" flag This is a summary of the discussion in #1269 and https://github.com/dotnet/sdk/issues/14642, and the .NET 5 discussion in dotnet/sdk#12035. * Add existing AssemblyMetadata example * PR feedback * Fix typo * Update docs/design/trimmed-assemblies.md Co-authored-by: Eric Erhardt <[email protected]> * Apply suggestions from code review Co-authored-by: Eric Erhardt <[email protected]> * PR feedback * Add notes about opt-out * Use present tense * Add more opt-out notes Co-authored-by: Eric Erhardt <[email protected]>
dotnet/linker#1269 (comment) proposes two new ways to configure trimming:
Currently, the
IsTrimmable
metadata in MSBuild controls which assemblies are trimmed (see https://docs.microsoft.com/en-us/dotnet/core/deploying/trimming-options#trimmed-assemblies). The metadata can be set on aPackageReference
and it will flow to the referenced assemblies, but setting it for individual assemblies requires adding this metadata at the appropriate step in the build with a custom target. The above suggestions would simplify this. For example:could be simplified to:
It would be important to clarify whether the ItemGroup refers to assemblies by name or by file path (it's more common for ItemGroups to represent files on disk). This is similar to the behavior of
TrimmerRootAssembly
.The text was updated successfully, but these errors were encountered: