trimming

A publishing option that removes code the trimmer can prove is unused, making a self-contained app or image smaller.

Trimming can silently remove code used through reflection and break the app at run time.

In more detail

It works by analysing which types and members the app can reach from its entry point. Code reached only through reflection or dynamic discovery can be removed wrongly, so read the trim warnings, run the published app and test reflection-heavy features before enabling it.

Example

dotnet publish -c Release -p:PublishTrimmed=true

Related terms

Taught in

References