Skip to content

Commit

Permalink
android-projects.md: New linker settings (#2211)
Browse files Browse the repository at this point in the history
* android-projects.md: New linker settings

Document new options and defaults for `TrimMode`. I took my best guess at the new content, but couldn’t find defninitive documentation. FWIW, here’s an AI-generated [overview of the changes](https://g.co/gemini/share/c84935d1940b).

* Update android-projects.md

* Update android-projects.md

---------

Co-authored-by: David Britch <davidbritch@users.noreply.github.com>
  • Loading branch information
breyed and davidbritch authored Jun 19, 2024
1 parent 6ce1269 commit 6330a64
Showing 1 changed file with 5 additions and 5 deletions.
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

0 comments on commit 6330a64

Please sign in to comment.