Skip to content

ASP.NET Core assemblies should participate in member-level trimming #29508

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

Closed
mthalman opened this issue Jan 21, 2021 · 3 comments
Closed

ASP.NET Core assemblies should participate in member-level trimming #29508

mthalman opened this issue Jan 21, 2021 · 3 comments
Labels
✔️ Resolution: Duplicate Resolved as a duplicate of another issue Status: Resolved

Comments

@mthalman
Copy link
Member

When using the TrimMode=Link publish option, none of the ASP.NET Core assemblies are affected. They all remain at their full size even if members within those assemblies are never accessed by a code path in the application.

Because of the quantity and size of the ASP.NET Core assemblies, there is a big opportunity to reduce the size of a deployed app if these assemblies participated in member-level trimming.

As an example, this sample ASP.NET Core application has the following trimmed container image sizes on Alpine Linux:

TrimMode Size
<Default> 98.5 MB
Link 80 MB

If the ASP.NET Core assemblies participated in assembly-level trimming, this reduction would be even greater.

Repro steps:

  1. git clone https://github.com/dotnet/dotnet-docker.git
  2. cd dotnet-docker/samples/aspnetapp
  3. docker build -t default-trimming -f Dockerfile.alpine-x64-slim .
  4. Modify Dockerfile.alpine-x64-slim to include /p:TrimMode=Link in the dotnet publish call
  5. docker build -t link-trimming -f Dockerfile.alpine-x64-slim .
  6. docker inspect --format "{{ .Size }}" default-trimming
  7. docker inspect --format "{{ .Size }}" link-trimming
@mthalman
Copy link
Member Author

cc @davidfowl, @eerhardt

@eerhardt
Copy link
Member

Duplicate of #27384?

@davidfowl
Copy link
Member

Yes

@davidfowl davidfowl added the ✔️ Resolution: Duplicate Resolved as a duplicate of another issue label Jan 21, 2021
@ghost ghost added the Status: Resolved label Jan 21, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Feb 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
✔️ Resolution: Duplicate Resolved as a duplicate of another issue Status: Resolved
Projects
None yet
Development

No branches or pull requests

3 participants