dotnet / dotnet/msbuild

Add more options to control trimming behavior

Open
#6,380 1 comment 2 reactions 0 assignees View on GitHub
triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 13h
Merged PRs (30d)
133

Description

https://github.com/mono/linker/issues/1269#issuecomment-731231382 proposes two new ways to configure trimming:
- Allow opting into trimming via an ItemGroup, not just via IsTrimmable metadata
- A property that simplifies opting everything into trimming: TrimAllAssemblies

Currently, the `IsTrimmable` metadata in MSBuild controls which assemblies are trimmed (see https://docs.microsoft.com/en-us/dotnet/core/deploying/trimming-options#trimmed-assemblies). The metadata can be set on a `PackageReference` and it will flow to the referenced assemblies, but setting it for individual assemblies requires adding this metadata at the appropriate step in the build with a custom target. The above suggestions would simplify this. For example:

```xml



true

```
could be simplified to:
```xml

```

It would be important to clarify whether the ItemGroup refers to assemblies by name or by file path (it's more common for ItemGroups to represent files on disk). This is similar to the behavior of [`TrimmerRootAssembly`](https://docs.microsoft.com/en-us/dotnet/core/deploying/trimming-options#root-assemblies).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.