Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android-projects.md: New linker settings #2211

Merged
merged 4 commits into from
Jun 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/migration/android-projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,21 @@ There are behavioral changes to the `String.IndexOf()` method in .NET 5+ on diff

## Linker

.NET 5+ has new settings for the linker:
.NET 8 has new settings for the linker:

- `<PublishTrimmed>true</PublishTrimmed>`
- `<TrimMode>link</TrimMode>`, which enables member-level trimming.
- `<TrimMode>partial</TrimMode>`, which trims assemblies that have opted-in to trimming.

For more information, see [Trimming options](/dotnet/core/deploying/trimming-options).

In .NET for Android projects by default, `Debug` builds don't use the linker, and `Release` builds set `PublishTrimmed=true` and `TrimMode=link`. `TrimMode=copyused` is the default for the .NET SDK but isn't appropriate for mobile apps. However, you can still opt into `TrimMode=copyused` if required.
In .NET for Android projects by default, `Debug` builds don't use the linker, and `Release` builds set `PublishTrimmed=true` and `TrimMode=partial`.

If the legacy `AndroidLinkMode` setting is used, both `SdkOnly` and `Full` default to equivalent linker settings:

- `<PublishTrimmed>true</PublishTrimmed>`
- `<TrimMode>link</TrimMode>`
- `<TrimMode>partial</TrimMode>`

With `AndroidLinkMode=SdkOnly`, only BCL and SDK assemblies marked with `%(Trimmable)` are linked at the member level. `AndroidLinkMode=Full` sets `%(TrimMode)=link` on all .NET assemblies.
With `AndroidLinkMode=SdkOnly`, only BCL and SDK assemblies marked with `%(Trimmable)` are linked at the member level. `AndroidLinkMode=Full` sets `%(TrimMode)=partial` on all .NET assemblies.

> [!TIP]
> You should migrate to the new linker settings, because the `AndroidLinkMode` setting will eventually be deprecated.
Expand Down
Loading