-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Support extending which assemblies are trimmable #12035
Comments
BackgroundThe SDK publish targets run It is worth reiterating that there are three conditions that influence the behavior:
Blazor has their own linker targets that run during build, which filter assemblies by filename to determine the linker behavior. For .NET5, they are planning to move to the built-in linker targets that run during publish. They need a place to hook into the pipeline where they can continue filtering assemblies by name, and also a way to set the linker default behavior to aggressive trimming instead of assembly-level trimming (which is the .NET SDK default). In addition, they generate custom "type-granularity" roots for some assemblies, which will be done in the same place. ProposalTrimModeTo enable aggressive trimming instead of assembly-level trimming, we provide a public property PrepareForILLinkWe will provide a new public target, The global ManagedAssemblyToLinkThis target will have a dependency that creates the ItemGroup It will be illegal to change the items in ExamplesThis shows how a developer could turn on aggressive trimming for framework assemblies (which are defined to be <PropertyGroup>
<TrimMode>link</TrimMode>
</PropertyGroup> This shows how Blazor (or a developer) could hook into the build to opt assemblies into different levels of trimming based on the filename: <Target Name="PrepareForBlazorILLink"
BeforeTargets="PrepareForILLink">
<PropertyGroup>
<!-- Set the default TrimMode for IsTrimmable assemblies -->
<TrimMode>link</TrimMode>
</PropertyGroup>
<ItemGroup>
<ManagedAssemblyToLink Condition="'$([System.String]::Copy('%(ManagedAssemblyToLink.Filename)').StartsWith('Microsoft.AspNetCore.'))">
<!-- Trim these assemblies using the global TrimMode -->
<IsTrimmable>true</IsTrimmable>
</ManagedAssemblyToLink>
<ManagedAssemblyToLink Condition="'$([System.String]::Copy('%(ManagedAssemblyToLink.Filename)').StartsWith('ThirdPartyAssembly.'))">
<!-- Trim these assemblies with assembly-level trimming. Implies IsTrimmable. -->
<TrimMode>copyused</TrimMode>
</ManagedAssemblyToLink>
</ItemGroup>
</Target> Notes
|
/cc @akoeplinger |
I think this proposal looks really good. Thanks for putting it together. I have a couple comments/questions:
|
Minor nit, The SDK typically names items in the singular e.g. |
Agreed. :( To explain how we got here: ILLink is used because it's the name of the tool (originally monolinker). PMs recommended to use "Trimmer" to describe the tool to the public and for the public-facing MSBuild options in 3.0. Now more of the extension points are reflecting naming conventions used by the tool - and we are even considering using the tool in an analysis mode, where the input assemblies, tentatively named If I were starting fresh, I might consider naming the project something like "IL Analyzer" or "IL Optimizer", and use "ManagedAssemblyToAnalyze", "AnalyzerAction: Trim", etc.
Edited above, thanks! |
An alternative to |
What about instead of |
I don't like the term "link" - I think it has too much history which is about tools not related to our "linker" functionality (there is some overlap, but relatively small and definitely hard to explain). Not counting that when we introduce true AOT, there might actually be a true platform linker in the toolchain as well - which would create lot of confusion. So in that sense I prefer anything else - "trim"/"trimmer" is at least unique enough. So going with that logic, I think we should name all public (and as much of internal ones as possible) properties/items with that term "trim". The above proposal looks good with the exception of As for the future analyze-only scenarios... if we have to I would be OK with using "trim" there as well (after all the trim part is by far the most complex and likely heavily used). Having an action "analyze" which would apply as the default or per-assembly would make that work reasonably well. If we could improve on that, then I would probably go with a completely separate set of properties/items - the example One other thing to consider - rename the actions - specifically "link" is just bad (see the above reasons). Not only it uses terminology which is typically associated with a different action, but even in the linker it makes little sense - it actually means "trim" or "sweep" or... but not "link" (whatever that means). So ideally the values used by the msbuild properties/items would be from a different set which align the terms with the above discussion. Implementation wise we could either do the translation in the msbuild or ILLink task, or we could teach linker to accept multiple values for the same thing. While we're at it, I think it's a good idea to design ahead and incorporate the "trim granularity" into it - so basically rename "copy" to "TrimAssembly" or similar which would then probably mean renaming "link" to "TrimMembers" - not bad. We don't have to support or even define all of those yet if we don't need to. Nit: For actions and related settings I would not use the name of the tool, but rather the name of the action, so: |
Adding @samsp-msft as the PM representative. |
Thanks for the feedback! How does the following sound?
My only concern is that I think it would make sense to do the translation in the task as long as there is a 1-to-1 mapping of these settings to |
I still don't understand why we need |
We also want non- There are two ways to set the That's how I think about it at least - but maybe there is a cleaner way to do it that I'm not seeing. |
I don't like this approach. I think we are just switching from one incorrect naming into another similarly incorrect naming. For illustration when someone sets TrimMode=TrimMembers you are actually instructing linker to remove resources, remove type-forwarders, drop interfaces, etc. Similarly for TrimMode=TrimAssembly, which is even more confusing. It seems to me we should make the option more user friendly and hide the implementation details and configuration options. We could do that by defining different modes/levels. For example, we could have
and we could tweak their underlying setting as we make more stuff reliable. |
Had an offline discussion with @marek-safar: This basically means that we should have one property which is the main knob for users to "play with". The So I think the most important change is to introduce (or rename) the
The next one is to define the per-assembly settings. I think the above proposal are OK - but I ended up agreeing with @marek-safar on not using the "TrimMembers"/"TrimAssembly" terminology. We could go with either the current names linker has for actions (copy, link, ...) or rename those. For simplicity we can probably keep the linker names - we can always rename them in the future (basically add aliases). I would try to stick to the terminology separation between the capability => "trim" and the tool => "ILLinker". |
I like the idea that these options should be user-friendly - though I would suggest that the configuration options we define should themselves be user-friendly so that we don't have to hide them. If we are going to be changing the meanings of the optimization levels over time, maybe they belong in the linker itself rather than in the MSBuild glue? That said, the proposed It sounds like the suggestion is to have
For both Does that match your intent @marek-safar @vitek-karas ? About |
To me that suggests using |
I think they should be defined in ILLink.Task
|
I don't like the Conservative vs Aggressive as it doesn't help the developer make an informed choice - our options should be clear about what level of shaking is involved. Its then much easier to reason about what the breakages and impact is.
DoNotTrim, DoNotModify, KeepAsIs |
This is what @eerhardt was suggesting this as well - to fold
We need a separate I've updated the proposal to use |
See dotnet#12035 - PrepareForILLink target - ManagedAssemblyToLink ItemGroup - TrimMode property and metadata - private _TrimmerCustomData (dotnet/linker#1134) - Allow setting `PublishTrimmed` in a late import.targets
Just to summarize the current state of the proposal:
|
Were we going to use different names for these modes? Or are we sticking with the linker .exe names? |
I am suggesting we stick with the linker names - see the notes in "Naming of TrimMode values" above for a summary of the feedback I've received. |
This proposal sounds good to me. I think it will address the short term needs for Blazor, and makes a good foundation for future improvements. |
I agree. Let's get this implemented in time for the last preview to test it works for the scenario |
* Add ILLink extension points See #12035 - PrepareForILLink target - ManagedAssemblyToLink ItemGroup - TrimMode property and metadata - private _TrimmerCustomData (dotnet/linker#1134) - Allow setting `PublishTrimmed` in a late import.targets * Add tests for extension points * Set Action in _RunILLink * Add notes about ManagedAssemblyToLink
Resolved with #12116. Closing. |
* Add ILLink extension points See #12035 - PrepareForILLink target - ManagedAssemblyToLink ItemGroup - TrimMode property and metadata - private _TrimmerCustomData (dotnet/linker#1134) - Allow setting `PublishTrimmed` in a late import.targets * Add tests for extension points * Set Action in _RunILLink * Add notes about ManagedAssemblyToLink Co-authored-by: Sven Boemer <[email protected]>
* Update dependencies from https://github.com/dotnet/templating build 20200622.1 Microsoft.TemplateEngine.Cli From Version 5.0.0-preview.8.20322.2 -> To Version 5.0.0-preview.7.20322.1 * Update dependencies from https://github.com/dotnet/runtime build 20200622.6 System.CodeDom , Microsoft.NET.HostModel , Microsoft.Extensions.DependencyModel , Microsoft.NETCore.App.Runtime.win-x64 , Microsoft.NETCore.DotNetHostResolver , Microsoft.NETCore.App.Ref , System.Text.Encoding.CodePages , System.Security.Cryptography.ProtectedData , System.Resources.Extensions From Version 5.0.0-preview.7.20322.7 -> To Version 5.0.0-preview.7.20322.6 * Update dependencies from https://github.com/microsoft/msbuild build 20200617.1 (#12147) Microsoft.Build.Localization , Microsoft.Build From Version 16.7.0-preview-20310-07 -> To Version 16.7.0-preview-20317-01 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/runtime build 20200623.4 System.CodeDom , Microsoft.NET.HostModel , Microsoft.Extensions.DependencyModel , Microsoft.NETCore.App.Runtime.win-x64 , Microsoft.NETCore.DotNetHostResolver , Microsoft.NETCore.App.Ref , System.Text.Encoding.CodePages , System.Security.Cryptography.ProtectedData , System.Resources.Extensions From Version 5.0.0-preview.7.20322.7 -> To Version 5.0.0-preview.7.20323.4 * Update dependencies from https://github.com/dotnet/fsharp build 20200623.3 (#12155) Microsoft.FSharp.Compiler From Version 10.10.0-beta.20322.7 -> To Version 10.10.0-beta.20323.3 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * [release/5.0.1xx-preview7] Update dependencies from nuget/nuget.client (#12148) * Update dependencies from https://github.com/NuGet/NuGet.Client build 5.7.0.6668 NuGet.Build.Tasks From Version 5.7.0-preview.3.6653 -> To Version 5.7.0-rtm.6668 * Update dependencies from https://github.com/NuGet/NuGet.Client build 5.7.0.6670 NuGet.Build.Tasks From Version 5.7.0-preview.3.6653 -> To Version 5.7.0-rtm.6670 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/windowsdesktop build 20200623.6 (#12161) Microsoft.WindowsDesktop.App From Version 5.0.0-preview.7.20311.4 -> To Version 5.0.0-preview.7.20323.6 Dependency coherency updates Microsoft.NET.Sdk.WindowsDesktop From Version 5.0.0-preview.7.20311.4 -> To Version 5.0.0-preview.7.20323.3 (parent: Microsoft.WindowsDesktop.App Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/windowsdesktop build 20200623.9 (#12163) Microsoft.WindowsDesktop.App From Version 5.0.0-preview.7.20323.6 -> To Version 5.0.0-preview.7.20323.9 Dependency coherency updates Microsoft.NET.Sdk.WindowsDesktop From Version 5.0.0-preview.7.20323.3 -> To Version 5.0.0-preview.7.20323.5 (parent: Microsoft.WindowsDesktop.App Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/windowsdesktop build 20200624.1 (#12169) Microsoft.WindowsDesktop.App From Version 5.0.0-preview.7.20323.9 -> To Version 5.0.0-preview.7.20324.1 Dependency coherency updates Microsoft.NET.Sdk.WindowsDesktop From Version 5.0.0-preview.7.20323.5 -> To Version 5.0.0-preview.7.20323.9 (parent: Microsoft.WindowsDesktop.App Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/aspnetcore build 20200623.1 (#12150) Microsoft.AspNetCore.Analyzers , Microsoft.NET.Sdk.Razor , Microsoft.AspNetCore.Components.Analyzers , Microsoft.AspNetCore.DeveloperCertificates.XPlat , Microsoft.AspNetCore.Mvc.Api.Analyzers , Microsoft.AspNetCore.Mvc.Analyzers From Version 5.0.0-preview.7.20311.11 -> To Version 5.0.0-preview.7.20323.1 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * [release/5.0.1xx-preview7] Update dependencies from dotnet/aspnetcore (#12176) * Update dependencies from https://github.com/dotnet/aspnetcore build 20200623.3 Microsoft.AspNetCore.Analyzers , Microsoft.NET.Sdk.Razor , Microsoft.AspNetCore.Components.Analyzers , Microsoft.AspNetCore.DeveloperCertificates.XPlat , Microsoft.AspNetCore.Mvc.Api.Analyzers , Microsoft.AspNetCore.Mvc.Analyzers From Version 5.0.0-preview.7.20323.1 -> To Version 5.0.0-preview.7.20323.3 * Update dependencies from https://github.com/dotnet/aspnetcore build 20200623.9 Microsoft.AspNetCore.Analyzers , Microsoft.NET.Sdk.Razor , Microsoft.AspNetCore.Components.Analyzers , Microsoft.AspNetCore.DeveloperCertificates.XPlat , Microsoft.AspNetCore.Mvc.Analyzers , Microsoft.AspNetCore.Mvc.Api.Analyzers From Version 5.0.0-preview.7.20323.3 -> To Version 5.0.0-preview.7.20323.9 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/microsoft/msbuild build 20200623.1 (#12158) Microsoft.Build.Localization , Microsoft.Build From Version 16.7.0-preview-20317-01 -> To Version 16.7.0-preview-20323-01 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Work around for runtime pack profiles with differing runtime IDs * Update dependencies from https://github.com/dotnet/aspnetcore build 20200625.9 (#12220) Microsoft.AspNetCore.Analyzers , Microsoft.NET.Sdk.Razor , Microsoft.AspNetCore.Components.Analyzers , Microsoft.AspNetCore.DeveloperCertificates.XPlat , Microsoft.AspNetCore.Mvc.Analyzers , Microsoft.AspNetCore.Mvc.Api.Analyzers From Version 5.0.0-preview.7.20323.9 -> To Version 5.0.0-preview.7.20325.9 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/fsharp build 20200626.1 (#12219) Microsoft.FSharp.Compiler From Version 10.10.0-beta.20323.3 -> To Version 10.10.0-beta.20326.1 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/runtime build 20200626.1 (#12221) System.CodeDom , Microsoft.NET.HostModel , Microsoft.Extensions.DependencyModel , Microsoft.NETCore.App.Runtime.win-x64 , Microsoft.NETCore.DotNetHostResolver , Microsoft.NETCore.App.Ref , System.Text.Encoding.CodePages , System.Security.Cryptography.ProtectedData , System.Resources.Extensions From Version 5.0.0-preview.7.20323.4 -> To Version 5.0.0-preview.7.20326.1 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * [release/5.0.1xx-preview7] Update dependencies from microsoft/msbuild (#12218) * Update dependencies from https://github.com/microsoft/msbuild build 20200626.1 Microsoft.Build.Localization , Microsoft.Build From Version 16.7.0-preview-20323-01 -> To Version 16.7.0-preview-20326-01 * Update dependencies from https://github.com/microsoft/msbuild build 20200626.6 Microsoft.Build.Localization , Microsoft.Build From Version 16.7.0-preview-20323-01 -> To Version 16.7.0-preview-20326-06 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * [release/5.0.1xx-preview7] Update dependencies from dotnet/aspnetcore (#12223) * Update dependencies from https://github.com/dotnet/aspnetcore build 20200626.3 Microsoft.AspNetCore.Analyzers , Microsoft.NET.Sdk.Razor , Microsoft.AspNetCore.Components.Analyzers , Microsoft.AspNetCore.DeveloperCertificates.XPlat , Microsoft.AspNetCore.Mvc.Analyzers , Microsoft.AspNetCore.Mvc.Api.Analyzers From Version 5.0.0-preview.7.20325.9 -> To Version 5.0.0-preview.7.20326.3 * Update dependencies from https://github.com/dotnet/aspnetcore build 20200626.5 Microsoft.AspNetCore.Analyzers , Microsoft.NET.Sdk.Razor , Microsoft.AspNetCore.Components.Analyzers , Microsoft.AspNetCore.DeveloperCertificates.XPlat , Microsoft.AspNetCore.Mvc.Analyzers , Microsoft.AspNetCore.Mvc.Api.Analyzers From Version 5.0.0-preview.7.20325.9 -> To Version 5.0.0-preview.7.20326.5 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/fsharp build 20200626.3 (#12225) Microsoft.FSharp.Compiler From Version 10.10.0-beta.20326.1 -> To Version 10.10.0-beta.20326.3 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/windowsdesktop build 20200626.3 (#12229) Microsoft.WindowsDesktop.App From Version 5.0.0-preview.7.20324.1 -> To Version 5.0.0-preview.7.20326.3 Dependency coherency updates Microsoft.NET.Sdk.WindowsDesktop From Version 5.0.0-preview.7.20323.9 -> To Version 5.0.0-preview.7.20326.3 (parent: Microsoft.WindowsDesktop.App Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * [release/5.0.1xx-preview7] Update dependencies from microsoft/msbuild (#12226) * Update dependencies from https://github.com/microsoft/msbuild build 20200626.2 Microsoft.Build.Localization , Microsoft.Build From Version 16.7.0-preview-20326-06 -> To Version 16.7.0-preview-20326-02 * Update dependencies from https://github.com/microsoft/msbuild build 20200626.3 Microsoft.Build.Localization , Microsoft.Build From Version 16.7.0-preview-20326-02 -> To Version 16.7.0-preview-20326-03 * Update dependencies from https://github.com/microsoft/msbuild build 20200626.5 Microsoft.Build.Localization , Microsoft.Build From Version 16.7.0-preview-20326-03 -> To Version 16.7.0-preview-20326-05 * Update dependencies from https://github.com/microsoft/msbuild build 20200626.4 Microsoft.Build.Localization , Microsoft.Build From Version 16.7.0-preview-20326-05 -> To Version 16.7.0-preview-20326-04 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/aspnetcore build 20200626.10 (#12235) Microsoft.AspNetCore.Analyzers , Microsoft.NET.Sdk.Razor , Microsoft.AspNetCore.Components.Analyzers , Microsoft.AspNetCore.DeveloperCertificates.XPlat , Microsoft.AspNetCore.Mvc.Analyzers , Microsoft.AspNetCore.Mvc.Api.Analyzers From Version 5.0.0-preview.7.20326.5 -> To Version 5.0.0-preview.7.20326.10 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * [release/5.0.1xx-preview7] Update dependencies from dotnet/aspnetcore (#12237) * Update dependencies from https://github.com/dotnet/aspnetcore build 20200626.12 Microsoft.AspNetCore.Analyzers , Microsoft.NET.Sdk.Razor , Microsoft.AspNetCore.Components.Analyzers , Microsoft.AspNetCore.DeveloperCertificates.XPlat , Microsoft.AspNetCore.Mvc.Analyzers , Microsoft.AspNetCore.Mvc.Api.Analyzers From Version 5.0.0-preview.7.20326.10 -> To Version 5.0.0-preview.7.20326.12 * Update dependencies from https://github.com/dotnet/aspnetcore build 20200626.13 Microsoft.AspNetCore.Analyzers , Microsoft.NET.Sdk.Razor , Microsoft.AspNetCore.Components.Analyzers , Microsoft.AspNetCore.DeveloperCertificates.XPlat , Microsoft.AspNetCore.Mvc.Analyzers , Microsoft.AspNetCore.Mvc.Api.Analyzers From Version 5.0.0-preview.7.20326.10 -> To Version 5.0.0-preview.7.20326.13 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/fsharp build 20200627.5 (#12244) Microsoft.FSharp.Compiler From Version 10.10.0-beta.20326.3 -> To Version 10.10.0-beta.20327.5 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/fsharp build 20200628.2 (#12250) Microsoft.FSharp.Compiler From Version 10.10.0-beta.20327.5 -> To Version 10.10.0-beta.20328.2 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/fsharp build 20200628.3 (#12252) Microsoft.FSharp.Compiler From Version 10.10.0-beta.20328.2 -> To Version 10.10.0-beta.20328.3 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/fsharp build 20200629.1 (#12258) Microsoft.FSharp.Compiler From Version 10.10.0-beta.20328.3 -> To Version 10.10.0-beta.20329.1 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/microsoft/msbuild build 20200629.2 (#12263) Microsoft.Build.Localization , Microsoft.Build From Version 16.7.0-preview-20326-04 -> To Version 16.7.0-preview-20329-02 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/aspnetcore build 20200629.4 (#12266) Microsoft.AspNetCore.Analyzers , Microsoft.NET.Sdk.Razor , Microsoft.AspNetCore.Components.Analyzers , Microsoft.AspNetCore.DeveloperCertificates.XPlat , Microsoft.AspNetCore.Mvc.Analyzers , Microsoft.AspNetCore.Mvc.Api.Analyzers From Version 5.0.0-preview.7.20326.13 -> To Version 5.0.0-preview.7.20329.4 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/fsharp build 20200629.4 (#12268) Microsoft.FSharp.Compiler From Version 10.10.0-beta.20329.1 -> To Version 10.10.0-beta.20329.4 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/fsharp build 20200629.5 (#12269) Microsoft.FSharp.Compiler From Version 10.10.0-beta.20329.4 -> To Version 10.10.0-beta.20329.5 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/microsoft/msbuild build 20200630.1 (#12273) Microsoft.Build.Localization , Microsoft.Build From Version 16.7.0-preview-20329-02 -> To Version 16.7.0-preview-20330-01 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Add ILLink extension points (#12116) (#12264) * Add ILLink extension points See #12035 - PrepareForILLink target - ManagedAssemblyToLink ItemGroup - TrimMode property and metadata - private _TrimmerCustomData (dotnet/linker#1134) - Allow setting `PublishTrimmed` in a late import.targets * Add tests for extension points * Set Action in _RunILLink * Add notes about ManagedAssemblyToLink Co-authored-by: Sven Boemer <[email protected]> * Update dependencies from https://github.com/microsoft/msbuild build 20200630.2 (#12275) Microsoft.Build.Localization , Microsoft.Build From Version 16.7.0-preview-20330-01 -> To Version 16.7.0-preview-20330-02 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/NuGet/NuGet.Client build 5.7.0.6677 (#12284) NuGet.Build.Tasks From Version 5.7.0-rtm.6670 -> To Version 5.7.0-rtm.6677 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/microsoft/msbuild build 20200630.6 (#12286) Microsoft.Build.Localization , Microsoft.Build From Version 16.7.0-preview-20330-02 -> To Version 16.7.0-preview-20330-06 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/aspnetcore build 20200630.2 (#12290) Microsoft.AspNetCore.Analyzers , Microsoft.NET.Sdk.Razor , Microsoft.AspNetCore.Components.Analyzers , Microsoft.AspNetCore.DeveloperCertificates.XPlat , Microsoft.AspNetCore.Mvc.Analyzers , Microsoft.AspNetCore.Mvc.Api.Analyzers From Version 5.0.0-preview.7.20329.4 -> To Version 5.0.0-preview.7.20330.2 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/aspnetcore build 20200630.5 (#12293) Microsoft.AspNetCore.Analyzers , Microsoft.NET.Sdk.Razor , Microsoft.AspNetCore.Components.Analyzers , Microsoft.AspNetCore.DeveloperCertificates.XPlat , Microsoft.AspNetCore.Mvc.Analyzers , Microsoft.AspNetCore.Mvc.Api.Analyzers From Version 5.0.0-preview.7.20330.2 -> To Version 5.0.0-preview.7.20330.5 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/microsoft/msbuild build 20200630.7 (#12294) Microsoft.Build.Localization , Microsoft.Build From Version 16.7.0-preview-20330-06 -> To Version 16.7.0-preview-20330-07 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/aspnetcore build 20200630.7 (#12299) Microsoft.AspNetCore.Analyzers , Microsoft.NET.Sdk.Razor , Microsoft.AspNetCore.Components.Analyzers , Microsoft.AspNetCore.DeveloperCertificates.XPlat , Microsoft.AspNetCore.Mvc.Analyzers , Microsoft.AspNetCore.Mvc.Api.Analyzers From Version 5.0.0-preview.7.20330.5 -> To Version 5.0.0-preview.7.20330.7 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/microsoft/msbuild build 20200630.8 (#12300) Microsoft.Build.Localization , Microsoft.Build From Version 16.7.0-preview-20330-07 -> To Version 16.7.0-preview-20330-08 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/aspnetcore build 20200630.10 (#12302) Microsoft.AspNetCore.Analyzers , Microsoft.NET.Sdk.Razor , Microsoft.AspNetCore.Components.Analyzers , Microsoft.AspNetCore.DeveloperCertificates.XPlat , Microsoft.AspNetCore.Mvc.Analyzers , Microsoft.AspNetCore.Mvc.Api.Analyzers From Version 5.0.0-preview.7.20330.7 -> To Version 5.0.0-preview.7.20330.10 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Updating the web deploy reference to 4.0.4 * Suppress NU1603 warning for Web Deploy package * Updating the version to 4.0.5 * [release/5.0.1xx-preview7] Update dependencies from dotnet/aspnetcore (#12369) * Update dependencies from https://github.com/dotnet/aspnetcore build 20200706.7 Microsoft.AspNetCore.Analyzers , Microsoft.NET.Sdk.Razor , Microsoft.AspNetCore.Components.Analyzers , Microsoft.AspNetCore.DeveloperCertificates.XPlat , Microsoft.AspNetCore.Mvc.Analyzers , Microsoft.AspNetCore.Mvc.Api.Analyzers From Version 5.0.0-preview.7.20330.10 -> To Version 5.0.0-preview.7.20356.7 * Update stage 0 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Jason Zhai <[email protected]> * Update dependencies from https://github.com/microsoft/msbuild build 20200706.3 (#12374) Microsoft.Build.Localization , Microsoft.Build From Version 16.7.0-preview-20330-08 -> To Version 16.7.0-preview-20356-03 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/NuGet/NuGet.Client build 5.7.0.6686 (#12378) NuGet.Build.Tasks From Version 5.7.0-rtm.6677 -> To Version 5.7.0-rtm.6686 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/microsoft/msbuild build 20200709.1 (#12390) Microsoft.Build.Localization , Microsoft.Build From Version 16.7.0-preview-20356-03 -> To Version 16.7.0-preview-20359-01 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/fsharp build 20200709.2 (#12410) Microsoft.FSharp.Compiler From Version 10.10.0-beta.20329.5 -> To Version 10.10.0-beta.20359.2 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/microsoft/msbuild build 20200710.3 (#12415) Microsoft.Build.Localization , Microsoft.Build From Version 16.7.0-preview-20359-01 -> To Version 16.7.0-preview-20360-03 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/aspnetcore build 20200710.2 (#12417) Microsoft.AspNetCore.Analyzers , Microsoft.NET.Sdk.Razor , Microsoft.AspNetCore.Components.Analyzers , Microsoft.AspNetCore.DeveloperCertificates.XPlat , Microsoft.AspNetCore.Mvc.Analyzers , Microsoft.AspNetCore.Mvc.Api.Analyzers From Version 5.0.0-preview.7.20356.7 -> To Version 5.0.0-preview.7.20360.2 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Reverting #12084 (#12418) * Update dependencies from https://github.com/NuGet/NuGet.Client build 5.7.0.6702 (#12428) NuGet.Build.Tasks From Version 5.7.0-rtm.6686 -> To Version 5.7.0-rtm.6702 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/fsharp build 20200711.3 (#12433) Microsoft.FSharp.Compiler From Version 10.10.0-beta.20359.2 -> To Version 10.10.0-beta.20361.3 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/roslyn build 20200714.1 (#12453) Microsoft.Net.Compilers.Toolset From Version 3.7.0-3.20312.3 -> To Version 3.7.0-4.20364.1 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/roslyn build 20200715.2 (#12469) Microsoft.Net.Compilers.Toolset From Version 3.7.0-4.20364.1 -> To Version 3.7.0-5.20365.2 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/aspnetcore build 20200715.7 (#12497) Microsoft.AspNetCore.Analyzers , Microsoft.NET.Sdk.Razor , Microsoft.AspNetCore.Components.Analyzers , Microsoft.AspNetCore.DeveloperCertificates.XPlat , Microsoft.AspNetCore.Mvc.Analyzers , Microsoft.AspNetCore.Mvc.Api.Analyzers From Version 5.0.0-preview.7.20360.2 -> To Version 5.0.0-preview.7.20365.7 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/roslyn build 20200716.1 (#12505) Microsoft.Net.Compilers.Toolset From Version 3.7.0-5.20365.2 -> To Version 3.7.0-5.20366.1 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * [release/5.0.1xx-preview7] Update dependencies from dotnet/runtime (#12493) * Update dependencies from https://github.com/dotnet/runtime build 20200714.6 System.CodeDom , Microsoft.NET.HostModel , Microsoft.Extensions.DependencyModel , Microsoft.NETCore.App.Runtime.win-x64 , Microsoft.NETCore.DotNetHostResolver , Microsoft.NETCore.App.Ref , System.Text.Encoding.CodePages , System.Security.Cryptography.ProtectedData , System.Resources.Extensions From Version 5.0.0-preview.7.20326.1 -> To Version 5.0.0-preview.7.20364.6 * Update dependencies from https://github.com/dotnet/runtime build 20200714.11 System.CodeDom , Microsoft.NET.HostModel , Microsoft.Extensions.DependencyModel , Microsoft.NETCore.App.Runtime.win-x64 , Microsoft.NETCore.DotNetHostResolver , Microsoft.NETCore.App.Ref , System.Text.Encoding.CodePages , System.Security.Cryptography.ProtectedData , System.Resources.Extensions From Version 5.0.0-preview.7.20326.1 -> To Version 5.0.0-preview.7.20364.11 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/aspnetcore build 20200715.16 (#12509) Microsoft.AspNetCore.Analyzers , Microsoft.NET.Sdk.Razor , Microsoft.AspNetCore.Components.Analyzers , Microsoft.AspNetCore.DeveloperCertificates.XPlat , Microsoft.AspNetCore.Mvc.Analyzers , Microsoft.AspNetCore.Mvc.Api.Analyzers From Version 5.0.0-preview.7.20365.7 -> To Version 5.0.0-preview.7.20365.16 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/aspnetcore build 20200715.19 (#12511) Microsoft.AspNetCore.Analyzers , Microsoft.NET.Sdk.Razor , Microsoft.AspNetCore.Components.Analyzers , Microsoft.AspNetCore.DeveloperCertificates.XPlat , Microsoft.AspNetCore.Mvc.Analyzers , Microsoft.AspNetCore.Mvc.Api.Analyzers From Version 5.0.0-preview.7.20365.16 -> To Version 5.0.0-preview.7.20365.19 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/windowsdesktop build 20200716.1 (#12512) Microsoft.WindowsDesktop.App From Version 5.0.0-preview.7.20326.3 -> To Version 5.0.0-preview.7.20366.1 Dependency coherency updates Microsoft.NET.Sdk.WindowsDesktop From Version 5.0.0-preview.7.20326.3 -> To Version 5.0.0-preview.7.20365.12 (parent: Microsoft.WindowsDesktop.App Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/roslyn build 20200716.7 (#12523) Microsoft.Net.Compilers.Toolset From Version 3.7.0-5.20366.1 -> To Version 3.7.0-5.20366.7 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> * Update dependencies from https://github.com/dotnet/roslyn build 20200717.1 (#12531) Microsoft.Net.Compilers.Toolset From Version 3.7.0-5.20366.7 -> To Version 3.7.0-5.20367.1 Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: v-qizh10 <[email protected]> Co-authored-by: Lukas Lansky <[email protected]> Co-authored-by: Eric Erhardt <[email protected]> Co-authored-by: Sven Boemer <[email protected]> Co-authored-by: Daniel Plaisted <[email protected]> Co-authored-by: Daniel Plaisted <[email protected]> Co-authored-by: Vijay Ramakrishnan <[email protected]> Co-authored-by: Vijay Ramakrishnan <[email protected]> Co-authored-by: Jason Zhai <[email protected]>
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]>
This is one of the most confusing specifications I have ever read from .NET :( Why isn't there a TrimMode None? I am getting bug reports from users about System.Private.CoreLib System.Object type not found and I have no way to know if it's being caused by this trimming magic. How do I set the behavior to be pre .NET Core App 3.0 days when nothing magical whatsoever was taking place? I don't want any brains or fancy algos. I just want everything to be linked and nothing to be removed. What is the default - does it vary by SDK like BackGroundServices, etc. It sounds like Blazor SDK has a different default, which is a bit odd if you ask me that depending on where a library is executed, the behavior of reflected code is completely different and potentially nonsensical. @vitek-karas You hit the NAIL on the head with your remarks that developers need simple flags to understand this. I read two blog posts about this and I kept thinking, OK, you added a new feature, how do I turn it off or easily prove it's turned off and not affecting my binaries? |
Besides this GitHub issue, These are the top Google Search results when I try to learn more about this stuff: https://devblogs.microsoft.com/dotnet/app-trimming-in-net-5/ Just food for thought on where there may be some miscommunication. When an (optimization) feature gets added, it's a good idea to think through how to disable it as easily as possible. Probably a good rule of thumb for other types of features as well, but doubly because pre-mature optimization is the root of all evil. The other lesson learned here might be to think through how feature flags apply across SDKs, and create basic conformance tests for what an official SDK should and shouldn't do. Specialty SDKs like Blazor may even be best off in a unique SDK namespace to indicate they don't follow the same approach as others. Just brainstorming. |
@jzabroski sorry this is causing you trouble. :( You may want to take a look at the user-facing documentation at https://aka.ms/dotnet-illink/. This design doc was meant for us working on the feature and for SDK authors, so it probably isn't the best place to learn about trimming. To answer your questions:
|
@jzabroski I would suggest filing an issue describing your problem so that it can be visible to the people in charge of setting the trimming defaults for Blazor. Trimming is an explicit opt-in optimization in most .NET workloads because of its potential to break apps. Trimmer also generates warnings whenever it's not sure whether a particular line of code is going to work after trimming (reflection that is hard to reason about statically, typically). The defaults are:
SDK owners can change these defaults. Blazor (and Xamarin) turns on trimming by default and turns warnings off. People on this pull request are not in charge of setting these defaults. |
The current linker defaults make it difficult to modify the linker behavior to achieve "aggressive" trimming. We should introduce an MSBuild property to turn on aggressive trimming - that is, to pass all linker inputs with the action "link" instead of "copy" or "copyused". We need to consider how this interacts with existing mechanisms to modify linker behavior on individual assemblies.
It should be possible to enable different levels of trimming on a per-assembly basis as well, especially by different SDK components. The primary use case we would like to support immediately is blazor.
The text was updated successfully, but these errors were encountered: