Closed
Description
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:
git clone https://github.com/dotnet/dotnet-docker.git
cd dotnet-docker/samples/aspnetapp
docker build -t default-trimming -f Dockerfile.alpine-x64-slim .
- Modify
Dockerfile.alpine-x64-slim
to include/p:TrimMode=Link
in thedotnet publish
call docker build -t link-trimming -f Dockerfile.alpine-x64-slim .
docker inspect --format "{{ .Size }}" default-trimming
docker inspect --format "{{ .Size }}" link-trimming