AspNetCore.Docs/aspnetcore/blazor/host-and-deploy/configure-trimmer.md

2.1 KiB

title author description monikerRange ms.author ms.custom ms.date no-loc uid
Configure the Trimmer for ASP.NET Core Blazor guardrex Learn how to control the Intermediate Language (IL) Linker (Trimmer) when building a Blazor app. >= aspnetcore-5.0 riande mvc 02/08/2021
Home
Privacy
Kestrel
appsettings.json
ASP.NET Core Identity
cookie
Cookie
Blazor
Blazor Server
Blazor WebAssembly
Identity
Let's Encrypt
Razor
SignalR
blazor/host-and-deploy/configure-trimmer

Configure the Trimmer for ASP.NET Core Blazor

Blazor WebAssembly performs Intermediate Language (IL) trimming to reduce the size of the published output. By default, trimming occurs when publishing an app.

Trimming may have detrimental effects. In apps that use reflection, the Trimmer often can't determine the required types for reflection at runtime. To trim apps that use reflection, the Trimmer must be informed about required types for reflection in both the app's code and in the packages or frameworks that the app depends on. The Trimmer is also unable to react to an app's dynamic behavior at runtime. To ensure the trimmed app works correctly once deployed, test published output frequently while developing.

To configure the Trimmer, see the Trimming options article in the .NET Fundamentals documentation, which includes guidance on the following subjects:

  • Disable trimming for the entire app with the <PublishTrimmed> property in the project file.
  • Control how aggressively unused IL is discarded by the Trimmer.
  • Stop the Trimmer from trimming specific assemblies.
  • "Root" assemblies for trimming.
  • Surface warnings for reflected types by setting the <SuppressTrimAnalysisWarnings> property to false in the project file.
  • Control symbol trimming and degugger support.
  • Set Trimmer features for trimming framework library features.

Additional resources