From 1f946c4dd4fa9931a4322b60754b6f02f7ed63ae Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Tue, 19 Jul 2022 16:11:09 -0700 Subject: [PATCH 01/19] Cleanup trimming options and document TrimMode=full,partial --- .../deploying/trimming/trimming-options.md | 49 +++++++++++++++---- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/docs/core/deploying/trimming/trimming-options.md b/docs/core/deploying/trimming/trimming-options.md index d865d857b0fcd..b3766f3c6f161 100644 --- a/docs/core/deploying/trimming/trimming-options.md +++ b/docs/core/deploying/trimming/trimming-options.md @@ -5,6 +5,7 @@ author: sbomer ms.author: svbomer ms.date: 08/25/2020 ms.topic: reference +zone-pivot-groups: dotnet-version --- # Trimming options @@ -20,12 +21,44 @@ Trimming with `PublishTrimmed` was introduced in .NET Core 3.0. The other option Place this setting in the project file to ensure that the setting applies during `dotnet build`, not just `dotnet publish`. +:::zone pivot="dotnet-7-0" + +This setting enables trimming and will trim all assemblies by default. In .NET 6, only assemblies which opted-in +to trimming via `[AssemblyMetadata("IsTrimmable", "True")]` would be trimmed by default. You can return to the +previous behavior by using `partial`. + +:::zone-end + +:::zone pivot="dotnet-6-0,dotnet-5-0" + This setting trims any assemblies that have been configured for trimming. With `Microsoft.NET.Sdk` in .NET 6, this includes any assemblies with `[AssemblyMetadata("IsTrimmable", "True")]`, which is the case for framework assemblies. In .NET 5, framework assemblies from the netcoreapp runtime pack are configured for trimming via `` MSBuild metadata. Other SDKs may define different defaults. Starting in .NET 6, this setting also enables the trim-compatibility [Roslyn analyzer](#roslyn-analyzer) and disables [features that are incompatible with trimming](#framework-features-disabled-when-trimming). +:::zone-end + ## Trimming granularity +:::zone pivot="dotnet-7-0" + +The default is to trim all assemblies in the app. This can be changed using the `TrimMode` property. + +To only trim assemblies which have opted-in to trimming, set + +```C# +partial +``` + +The default setting is + +```C# +full +``` + +:::zone-end + +:::zone pivot="dotnet-6-0,dotnet-5-0" + The following granularity settings control how aggressively unused IL is discarded. This can be set as a property affecting all trimmer input assemblies, or as metadata on an [individual assembly](#trimmed-assemblies), which overrides the property setting. - `link` @@ -56,7 +89,9 @@ The framework libraries have this attribute. In .NET 6+, you can also opt in to This is equivalent to setting MSBuild metadata `true` for the assembly in `ManagedAssemblyToLink` (see below). -## Trimmed assemblies +:::zone-end + +## Trimming settings for individual assemblies When publishing a trimmed app, the SDK computes an `ItemGroup` called `ManagedAssemblyToLink` that represents the set of files to be processed for trimming. `ManagedAssemblyToLink` may have metadata that controls the trimming behavior per assembly. To set this metadata, create a target that runs before the built-in `PrepareForILLink` target. The following example shows how to enable trimming of `MyAssembly`. @@ -79,10 +114,14 @@ Do not add or remove items to/from `ManagedAssemblyToLink`, because the SDK comp Control whether the given assembly is trimmed. +:::zone pivot="dotnet-6-0,dotnet-5-0" + - `copyused` or `link` Control the [trimming granularity](#trimming-granularity) of this assembly. This takes precedence over the global `TrimMode`. Setting `TrimMode` on an assembly implies `true`. +:::zone-end + - `True` or `False` Control whether to show [single warnings](#show-detailed-warnings) for this assembly. @@ -135,14 +174,6 @@ Setting `PublishTrimmed` in .NET 6+ also enables a Roslyn analyzer that shows a Enable a Roslyn analyzer for a subset of trim analysis warnings. -## Warning versions - -Trim analysis respects the [`AnalysisLevel`](../../project-sdk/msbuild-props.md#analysislevel) property that controls the version of analysis warnings across the SDK. The `ILLinkWarningLevel` property controls the version of trim analysis warnings independently (similar to `WarningLevel` for the compiler): - -- `5` - - Emit only warnings of the given level or lower. To include all warning versions, set the value to `9999`. - ## Suppress warnings You can suppress individual [warning codes](https://github.com/dotnet/linker/blob/main/docs/error-codes.md#warning-codes) using the usual MSBuild properties respected by the toolchain, including `NoWarn`, `WarningsAsErrors`, `WarningsNotAsErrors`, and `TreatWarningsAsErrors`. There is an additional option that controls the ILLink warn-as-error behavior independently: From ae6b509fee0805c505de503224768a96402252ef Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Tue, 19 Jul 2022 16:45:01 -0700 Subject: [PATCH 02/19] Re-add mention in .NET 7 of TrimmableAssembly --- docs/core/deploying/trimming/trimming-options.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/core/deploying/trimming/trimming-options.md b/docs/core/deploying/trimming/trimming-options.md index b3766f3c6f161..503daab7de49f 100644 --- a/docs/core/deploying/trimming/trimming-options.md +++ b/docs/core/deploying/trimming/trimming-options.md @@ -81,6 +81,12 @@ In .NET 6+, `PublishTrimmed` trims assemblies with the following assembly-level The framework libraries have this attribute. In .NET 6+, you can also opt in to trimming for a library without this attribute, specifying the assembly by name (without the `.dll` extension). +:::zone-end + +:::zone pivot="dotnet-7-0" +In .NET 7, `full` is the default, but if you change the trim mode to `partial`, you can +opt-in individual assemblies to trimming. + ```xml @@ -89,7 +95,6 @@ The framework libraries have this attribute. In .NET 6+, you can also opt in to This is equivalent to setting MSBuild metadata `true` for the assembly in `ManagedAssemblyToLink` (see below). -:::zone-end ## Trimming settings for individual assemblies From afe2bd99c40f4fed626191b12cd8300beec6665e Mon Sep 17 00:00:00 2001 From: David Pine Date: Wed, 20 Jul 2022 07:41:37 -0500 Subject: [PATCH 03/19] Apply suggestions from code review --- docs/core/deploying/trimming/trimming-options.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/core/deploying/trimming/trimming-options.md b/docs/core/deploying/trimming/trimming-options.md index 503daab7de49f..6aad60c22c552 100644 --- a/docs/core/deploying/trimming/trimming-options.md +++ b/docs/core/deploying/trimming/trimming-options.md @@ -45,13 +45,13 @@ The default is to trim all assemblies in the app. This can be changed using the To only trim assemblies which have opted-in to trimming, set -```C# +```csharp partial ``` The default setting is -```C# +```csharp full ``` @@ -95,7 +95,6 @@ opt-in individual assemblies to trimming. This is equivalent to setting MSBuild metadata `true` for the assembly in `ManagedAssemblyToLink` (see below). - ## Trimming settings for individual assemblies When publishing a trimmed app, the SDK computes an `ItemGroup` called `ManagedAssemblyToLink` that represents the set of files to be processed for trimming. `ManagedAssemblyToLink` may have metadata that controls the trimming behavior per assembly. To set this metadata, create a target that runs before the built-in `PrepareForILLink` target. The following example shows how to enable trimming of `MyAssembly`. From 393c715a22423c8c42f84e8332fce1365a05f8f2 Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Wed, 20 Jul 2022 10:24:35 -0700 Subject: [PATCH 04/19] Cleanup language around TrimmerRootAssembly --- docs/core/deploying/trimming/trimming-options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/deploying/trimming/trimming-options.md b/docs/core/deploying/trimming/trimming-options.md index 6aad60c22c552..65ab66ecffa6c 100644 --- a/docs/core/deploying/trimming/trimming-options.md +++ b/docs/core/deploying/trimming/trimming-options.md @@ -132,7 +132,7 @@ Do not add or remove items to/from `ManagedAssemblyToLink`, because the SDK comp ## Root assemblies -All assemblies that do not have `true` are considered roots for the analysis, which means that they and all of their statically understood dependencies will be kept. Additional assemblies may be "rooted" by name (without the `.dll` extension): +If an assembly is not trimmed it is considered "rooted", which means that it and all of its statically understood dependencies will be kept. Additional assemblies may be "rooted" by name (without the `.dll` extension): ```xml From dc9b25a4ce7d9892ceb6d9e2f08d868342a19ee7 Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Wed, 20 Jul 2022 10:37:43 -0700 Subject: [PATCH 05/19] Hide individual assembly settings --- docs/core/deploying/trimming/trimming-options.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/core/deploying/trimming/trimming-options.md b/docs/core/deploying/trimming/trimming-options.md index 65ab66ecffa6c..c172af6b1c89f 100644 --- a/docs/core/deploying/trimming/trimming-options.md +++ b/docs/core/deploying/trimming/trimming-options.md @@ -95,6 +95,8 @@ opt-in individual assemblies to trimming. This is equivalent to setting MSBuild metadata `true` for the assembly in `ManagedAssemblyToLink` (see below). +:::zone pivot="dotnet-6-0,dotnet-5-0" + ## Trimming settings for individual assemblies When publishing a trimmed app, the SDK computes an `ItemGroup` called `ManagedAssemblyToLink` that represents the set of files to be processed for trimming. `ManagedAssemblyToLink` may have metadata that controls the trimming behavior per assembly. To set this metadata, create a target that runs before the built-in `PrepareForILLink` target. The following example shows how to enable trimming of `MyAssembly`. @@ -118,18 +120,16 @@ Do not add or remove items to/from `ManagedAssemblyToLink`, because the SDK comp Control whether the given assembly is trimmed. -:::zone pivot="dotnet-6-0,dotnet-5-0" - - `copyused` or `link` Control the [trimming granularity](#trimming-granularity) of this assembly. This takes precedence over the global `TrimMode`. Setting `TrimMode` on an assembly implies `true`. -:::zone-end - - `True` or `False` Control whether to show [single warnings](#show-detailed-warnings) for this assembly. +:::zone-end + ## Root assemblies If an assembly is not trimmed it is considered "rooted", which means that it and all of its statically understood dependencies will be kept. Additional assemblies may be "rooted" by name (without the `.dll` extension): @@ -194,8 +194,6 @@ In .NET 6+, trim analysis produces at most one warning for each assembly that co Show all detailed warnings, instead of collapsing them to a single warning per assembly. -The defaults show detailed warnings for the project assembly and `ProjectReference` items. `` can also be set as metadata on an [individual assembly](#trimmed-assemblies) to control the warning behavior for that assembly only. - ## Remove symbols Symbols are usually trimmed to match the trimmed assemblies. You can also remove all symbols: From 3c1be9868673cbc70ec5a794b7ff6abf30edf993 Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Wed, 20 Jul 2022 17:02:15 -0700 Subject: [PATCH 06/19] Respond to PR comments --- docs/core/deploying/trimming/trimming-options.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/core/deploying/trimming/trimming-options.md b/docs/core/deploying/trimming/trimming-options.md index c172af6b1c89f..d63b6ef98469b 100644 --- a/docs/core/deploying/trimming/trimming-options.md +++ b/docs/core/deploying/trimming/trimming-options.md @@ -31,7 +31,7 @@ previous behavior by using `partial`. :::zone pivot="dotnet-6-0,dotnet-5-0" -This setting trims any assemblies that have been configured for trimming. With `Microsoft.NET.Sdk` in .NET 6, this includes any assemblies with `[AssemblyMetadata("IsTrimmable", "True")]`, which is the case for framework assemblies. In .NET 5, framework assemblies from the netcoreapp runtime pack are configured for trimming via `` MSBuild metadata. Other SDKs may define different defaults. +This setting trims any assemblies that have been configured for trimming. With `Microsoft.NET.Sdk` in .NET 6, this includes any assemblies with `[AssemblyMetadata("IsTrimmable", "True")]`, which is the case for the .NET core framework assemblies. In .NET 5, framework assemblies from the netcoreapp runtime pack are configured for trimming via `` MSBuild metadata. Other SDKs may define different defaults. Starting in .NET 6, this setting also enables the trim-compatibility [Roslyn analyzer](#roslyn-analyzer) and disables [features that are incompatible with trimming](#framework-features-disabled-when-trimming). @@ -49,7 +49,7 @@ To only trim assemblies which have opted-in to trimming, set partial ``` -The default setting is +The default setting is ```csharp full From 40301ce8f8665d7e7f05dc23bae14d231624ed8b Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Wed, 20 Jul 2022 17:05:13 -0700 Subject: [PATCH 07/19] Fix link --- docs/core/deploying/trimming/trimming-options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/deploying/trimming/trimming-options.md b/docs/core/deploying/trimming/trimming-options.md index d63b6ef98469b..05b5ba95eb34e 100644 --- a/docs/core/deploying/trimming/trimming-options.md +++ b/docs/core/deploying/trimming/trimming-options.md @@ -59,7 +59,7 @@ The default setting is :::zone pivot="dotnet-6-0,dotnet-5-0" -The following granularity settings control how aggressively unused IL is discarded. This can be set as a property affecting all trimmer input assemblies, or as metadata on an [individual assembly](#trimmed-assemblies), which overrides the property setting. +The following granularity settings control how aggressively unused IL is discarded. This can be set as a property affecting all trimmer input assemblies, or as metadata on an [individual assembly](#trim-settings-for-individual-assemblies), which overrides the property setting. - `link` From ceb06ea39033ff7529baee28ea663d9e85d6db76 Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Wed, 20 Jul 2022 17:07:23 -0700 Subject: [PATCH 08/19] Update docs/core/deploying/trimming/trimming-options.md Co-authored-by: Jan Kotas --- docs/core/deploying/trimming/trimming-options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/deploying/trimming/trimming-options.md b/docs/core/deploying/trimming/trimming-options.md index 05b5ba95eb34e..02c38ac9f4388 100644 --- a/docs/core/deploying/trimming/trimming-options.md +++ b/docs/core/deploying/trimming/trimming-options.md @@ -31,7 +31,7 @@ previous behavior by using `partial`. :::zone pivot="dotnet-6-0,dotnet-5-0" -This setting trims any assemblies that have been configured for trimming. With `Microsoft.NET.Sdk` in .NET 6, this includes any assemblies with `[AssemblyMetadata("IsTrimmable", "True")]`, which is the case for the .NET core framework assemblies. In .NET 5, framework assemblies from the netcoreapp runtime pack are configured for trimming via `` MSBuild metadata. Other SDKs may define different defaults. +This setting trims any assemblies that have been configured for trimming. With `Microsoft.NET.Sdk` in .NET 6, this includes any assemblies with `[AssemblyMetadata("IsTrimmable", "True")]`, which is the case for the .NET runtime assemblies. In .NET 5, assemblies from the netcoreapp runtime pack are configured for trimming via `` MSBuild metadata. Other SDKs may define different defaults. Starting in .NET 6, this setting also enables the trim-compatibility [Roslyn analyzer](#roslyn-analyzer) and disables [features that are incompatible with trimming](#framework-features-disabled-when-trimming). From 320dd6a2e3dc3dd4f99b80e3b20881a6c857c4f3 Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Wed, 20 Jul 2022 17:16:38 -0700 Subject: [PATCH 09/19] Fix zones --- docs/core/deploying/trimming/trimming-options.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/core/deploying/trimming/trimming-options.md b/docs/core/deploying/trimming/trimming-options.md index 02c38ac9f4388..9afd45e2eb904 100644 --- a/docs/core/deploying/trimming/trimming-options.md +++ b/docs/core/deploying/trimming/trimming-options.md @@ -5,7 +5,7 @@ author: sbomer ms.author: svbomer ms.date: 08/25/2020 ms.topic: reference -zone-pivot-groups: dotnet-version +zone_pivot_groups: dotnet-version --- # Trimming options @@ -59,7 +59,7 @@ The default setting is :::zone pivot="dotnet-6-0,dotnet-5-0" -The following granularity settings control how aggressively unused IL is discarded. This can be set as a property affecting all trimmer input assemblies, or as metadata on an [individual assembly](#trim-settings-for-individual-assemblies), which overrides the property setting. +The following granularity settings control how aggressively unused IL is discarded. This can be set as a property affecting all trimmer input assemblies, or as metadata on an [individual assembly](#trimming-settings-for-individual-assemblies), which overrides the property setting. - `link` @@ -95,6 +95,8 @@ opt-in individual assemblies to trimming. This is equivalent to setting MSBuild metadata `true` for the assembly in `ManagedAssemblyToLink` (see below). +:::zone-end + :::zone pivot="dotnet-6-0,dotnet-5-0" ## Trimming settings for individual assemblies From 1db4837fae2122633ad28477d84ea66b6b9dfde7 Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Wed, 20 Jul 2022 17:46:49 -0700 Subject: [PATCH 10/19] Use dotnet-3-1 zone once --- docs/core/deploying/trimming/trimming-options.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/core/deploying/trimming/trimming-options.md b/docs/core/deploying/trimming/trimming-options.md index 9afd45e2eb904..248e1b2862afc 100644 --- a/docs/core/deploying/trimming/trimming-options.md +++ b/docs/core/deploying/trimming/trimming-options.md @@ -7,12 +7,15 @@ ms.date: 08/25/2020 ms.topic: reference zone_pivot_groups: dotnet-version --- + +:::zone pivot="dotnet-7-0,dotnet-6-0,dotnet-5-0,dotnet-3-1" # Trimming options The following MSBuild properties and items influence the behavior of [trimmed self-contained deployments](trim-self-contained.md). Some of the options mention `ILLink`, which is the name of the underlying tool that implements trimming. For more information about the underlying tool, see the [Trimmer documentation](https://github.com/dotnet/linker/tree/main/docs). Trimming with `PublishTrimmed` was introduced in .NET Core 3.0. The other options are available only in .NET 5 and later versions. + ## Enable trimming - `true` @@ -21,6 +24,8 @@ Trimming with `PublishTrimmed` was introduced in .NET Core 3.0. The other option Place this setting in the project file to ensure that the setting applies during `dotnet build`, not just `dotnet publish`. +:::end-zone + :::zone pivot="dotnet-7-0" This setting enables trimming and will trim all assemblies by default. In .NET 6, only assemblies which opted-in From 54cd90ed1d3ceeede8963c0480f48a6c1551f7f8 Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Thu, 21 Jul 2022 14:52:54 -0700 Subject: [PATCH 11/19] Fix warnings --- docs/core/deploying/trimming/trimming-options.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/core/deploying/trimming/trimming-options.md b/docs/core/deploying/trimming/trimming-options.md index 248e1b2862afc..93e678c782253 100644 --- a/docs/core/deploying/trimming/trimming-options.md +++ b/docs/core/deploying/trimming/trimming-options.md @@ -8,7 +8,8 @@ ms.topic: reference zone_pivot_groups: dotnet-version --- -:::zone pivot="dotnet-7-0,dotnet-6-0,dotnet-5-0,dotnet-3-1" +:::zone pivot="dotnet-7-0,dotnet-6-0,dotnet-5-0,dotnet-core-3-1" + # Trimming options The following MSBuild properties and items influence the behavior of [trimmed self-contained deployments](trim-self-contained.md). Some of the options mention `ILLink`, which is the name of the underlying tool that implements trimming. For more information about the underlying tool, see the [Trimmer documentation](https://github.com/dotnet/linker/tree/main/docs). From f4dc9b19a9b8dd51fd5df5731897fcffe8e81d11 Mon Sep 17 00:00:00 2001 From: David Pine Date: Thu, 21 Jul 2022 17:33:00 -0500 Subject: [PATCH 12/19] Update docs/core/deploying/trimming/trimming-options.md --- docs/core/deploying/trimming/trimming-options.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/core/deploying/trimming/trimming-options.md b/docs/core/deploying/trimming/trimming-options.md index 93e678c782253..818c1323a5ffe 100644 --- a/docs/core/deploying/trimming/trimming-options.md +++ b/docs/core/deploying/trimming/trimming-options.md @@ -16,7 +16,6 @@ The following MSBuild properties and items influence the behavior of [trimmed se Trimming with `PublishTrimmed` was introduced in .NET Core 3.0. The other options are available only in .NET 5 and later versions. - ## Enable trimming - `true` From a159d745758207086455eff34e3d01685d475192 Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Thu, 21 Jul 2022 16:40:39 -0700 Subject: [PATCH 13/19] Zone typo --- docs/core/deploying/trimming/trimming-options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/deploying/trimming/trimming-options.md b/docs/core/deploying/trimming/trimming-options.md index 818c1323a5ffe..b97caa3e40cc3 100644 --- a/docs/core/deploying/trimming/trimming-options.md +++ b/docs/core/deploying/trimming/trimming-options.md @@ -24,7 +24,7 @@ Trimming with `PublishTrimmed` was introduced in .NET Core 3.0. The other option Place this setting in the project file to ensure that the setting applies during `dotnet build`, not just `dotnet publish`. -:::end-zone +:::zone-end :::zone pivot="dotnet-7-0" From 7c4121a7adb00cc4c95967a07a6090cff29538e5 Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Fri, 22 Jul 2022 13:02:59 -0700 Subject: [PATCH 14/19] Respond to PR comments --- docs/core/deploying/trimming/trimming-options.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/core/deploying/trimming/trimming-options.md b/docs/core/deploying/trimming/trimming-options.md index b97caa3e40cc3..1e8efd97ba9a9 100644 --- a/docs/core/deploying/trimming/trimming-options.md +++ b/docs/core/deploying/trimming/trimming-options.md @@ -38,10 +38,10 @@ previous behavior by using `partial`. This setting trims any assemblies that have been configured for trimming. With `Microsoft.NET.Sdk` in .NET 6, this includes any assemblies with `[AssemblyMetadata("IsTrimmable", "True")]`, which is the case for the .NET runtime assemblies. In .NET 5, assemblies from the netcoreapp runtime pack are configured for trimming via `` MSBuild metadata. Other SDKs may define different defaults. -Starting in .NET 6, this setting also enables the trim-compatibility [Roslyn analyzer](#roslyn-analyzer) and disables [features that are incompatible with trimming](#framework-features-disabled-when-trimming). - :::zone-end +This setting also enables the trim-compatibility [Roslyn analyzer](#roslyn-analyzer) and disables [features that are incompatible with trimming](#framework-features-disabled-when-trimming). + ## Trimming granularity :::zone pivot="dotnet-7-0" From 5cb7fc8d2f2bd028f578834cc23cc1f492ebbd5f Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Tue, 2 Aug 2022 15:57:14 -0700 Subject: [PATCH 15/19] Update docs/core/deploying/trimming/trimming-options.md Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> --- docs/core/deploying/trimming/trimming-options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/deploying/trimming/trimming-options.md b/docs/core/deploying/trimming/trimming-options.md index 1e8efd97ba9a9..5e3e0126bf147 100644 --- a/docs/core/deploying/trimming/trimming-options.md +++ b/docs/core/deploying/trimming/trimming-options.md @@ -28,7 +28,7 @@ Place this setting in the project file to ensure that the setting applies during :::zone pivot="dotnet-7-0" -This setting enables trimming and will trim all assemblies by default. In .NET 6, only assemblies which opted-in +This setting enables trimming and will trim all assemblies by default. In .NET 6, only assemblies that opted-in to trimming via `[AssemblyMetadata("IsTrimmable", "True")]` would be trimmed by default. You can return to the previous behavior by using `partial`. From 3158eb001d8facfab8fc2c495d5c9eaa5c20bc8c Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Tue, 2 Aug 2022 15:57:28 -0700 Subject: [PATCH 16/19] Update docs/core/deploying/trimming/trimming-options.md Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> --- docs/core/deploying/trimming/trimming-options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/deploying/trimming/trimming-options.md b/docs/core/deploying/trimming/trimming-options.md index 5e3e0126bf147..825e0d1e90c7c 100644 --- a/docs/core/deploying/trimming/trimming-options.md +++ b/docs/core/deploying/trimming/trimming-options.md @@ -48,7 +48,7 @@ This setting also enables the trim-compatibility [Roslyn analyzer](#roslyn-analy The default is to trim all assemblies in the app. This can be changed using the `TrimMode` property. -To only trim assemblies which have opted-in to trimming, set +To only trim assemblies that have opted-in to trimming, set the property to `partial`: ```csharp partial From 47768982675766de94e70410f9234444f320808f Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Tue, 2 Aug 2022 15:57:35 -0700 Subject: [PATCH 17/19] Update docs/core/deploying/trimming/trimming-options.md Co-authored-by: Genevieve Warren <24882762+gewarren@users.noreply.github.com> --- docs/core/deploying/trimming/trimming-options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/deploying/trimming/trimming-options.md b/docs/core/deploying/trimming/trimming-options.md index 825e0d1e90c7c..ffb16fe3f19b9 100644 --- a/docs/core/deploying/trimming/trimming-options.md +++ b/docs/core/deploying/trimming/trimming-options.md @@ -54,7 +54,7 @@ To only trim assemblies that have opted-in to trimming, set the property to `par partial ``` -The default setting is +The default setting is `full`: ```csharp full From e0b3a6587531df907be0ff14d9086fcbba23f1bd Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Wed, 3 Aug 2022 13:14:26 -0700 Subject: [PATCH 18/19] Update trimming-options.md --- docs/core/deploying/trimming/trimming-options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/deploying/trimming/trimming-options.md b/docs/core/deploying/trimming/trimming-options.md index ffb16fe3f19b9..af339d459fa33 100644 --- a/docs/core/deploying/trimming/trimming-options.md +++ b/docs/core/deploying/trimming/trimming-options.md @@ -98,7 +98,7 @@ opt-in individual assemblies to trimming. ``` -This is equivalent to setting MSBuild metadata `true` for the assembly in `ManagedAssemblyToLink` (see below). +This is equivalent to setting `[AssemblyMetadata("IsTrimmable", "True")]` when building the assembly. :::zone-end From f0eda399c189634c3aee1a356b9821ebc4daf786 Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Wed, 3 Aug 2022 14:42:08 -0700 Subject: [PATCH 19/19] Update trim options summary table --- docs/core/project-sdk/msbuild-props.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/core/project-sdk/msbuild-props.md b/docs/core/project-sdk/msbuild-props.md index b75b3f90bc49a..39dc5b2607eb7 100644 --- a/docs/core/project-sdk/msbuild-props.md +++ b/docs/core/project-sdk/msbuild-props.md @@ -413,10 +413,9 @@ Numerous MSBuild properties are available to fine tune trimming, which is a feat | Property | Values | Description | | - | - | - | | `PublishTrimmed` | `true` or `false` | Controls whether trimming is enabled during publish. | -| `TrimMode` | `link` or `copyused` | Controls the trimming granularity. This property can be set globally for the project, or at the assembly level as metadata. | +| `TrimMode` | `full` or `partial` | Default is `full`. Controls the trimming granularity. | | `SuppressTrimAnalysisWarnings` | `true` or `false` | Controls whether trim analysis warnings are produced. | | `EnableTrimAnalyzer` | `true` or `false` | Controls whether a subset of trim analysis warnings are produced. You can enable analysis even if `PublishTrimmed` is set to `false`. | -| `ILLinkWarningLevel` | 5-9999, `preview`, or `latest` | Controls the version of trim analysis warnings. | | `ILLinkTreatWarningsAsErrors` | `true` or `false` | Controls whether trim warnings are treated as errors. For example, you may want to set this property to `false` when `TreatWarningsAsErrors` is set to `true`. | | `TrimmerSingleWarn` | `true` or `false` | Controls whether a single warning per assembly is shown or all warnings. | | `TrimmerRemoveSymbols` | `true` or `false` | Controls whether all symbols are removed from a trimmed application. |