-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Use linker extensibility to enable better trimming #23512
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
Conversation
pranavkm
commented
Jun 30, 2020
- Configure TrimmerDefaults=link if unspecified
- Allow Microsoft.AspNetCore.* and Microsoft.Extensions.* packages to be trimmed.
* Configure TrimmerDefaults=link if unspecified * Allow Microsoft.AspNetCore.* and Microsoft.Extensions.* packages to be trimmed.
| using (var file = File.OpenRead(assemblyPath)) | ||
| { | ||
| var peReader = new PEReader(file); | ||
| using var peReader = new PEReader(file); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
...osoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.Components.Wasm.targets
Show resolved
Hide resolved
|
|
||
| <ManagedAssemblyToLink | ||
| IsTrimmable="true" | ||
| Condition="'%(Extension)' == '.dll' AND ($([System.String]::Copy('%(Filename)').StartsWith('Microsoft.AspNetCore.')) or $([System.String]::Copy('%(Filename)').StartsWith('Microsoft.Extensions.')))" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(minor) I think there is a way to not duplicate this condition, and instead just use @(_BlazorTypeGranularAssembly) to update these ManagedAssemblyToLink items.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that by removing and adding it? ItemGroup Update doesn't work inside of a target.
eerhardt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| public override bool Execute() | ||
| { | ||
| using var fileStream = File.Create(TrimmerFile.ItemSpec); | ||
| var rootDescriptor = CreateRootDescriptorContents(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding the extra package file uncovered an issue with publish incrementalism. We were always writing a new trimmer descriptor which would cause the linker to be non-incremental. The task was updated to use the same pattern as WriteLinesToFile.WriteOnlyWhenDifferent
|
With this change, you should also be able to remove this line: aspnetcore/src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/LinkerWorkaround.xml Lines 27 to 28 in 71e388e
|
|
Thanks @eerhardt. I'll do that as a follow up once I've tested it. We don't have any test coverage for trimmed projects in this branch. |
