dotnet / dotnet/android

[.NET 10] change default value for `PublishTrimmed`

Open
#9,526 0 comments 1 reaction 2 assignees Claimed by @jonathanpeppers View on GitHub
Area: App+Library Build enhancement
Dominant language
C#
Stars
2.1k
Forks
579
Avg merge
1d 20h
Merged PRs (30d)
257

Description

### Android framework version

net9.0-android

### Affected platform version

any

### Description

Context: https://github.com/dotnet/android/pull/9525
Context: https://github.com/dotnet/runtime/issues/109724

As seen in the above issue, there is currently the expectation in .NET:

* `PublishTrimmed=true` set for all configurations, it means "I intend to trim this project"
* Not all builds need to actually run `illink`. For console apps, `dotnet build` doesn't trim or `illink`, `dotnet publish` _does_ trim and run `illink`.
* .NET SDK sets various feature switches based on `PublishTrimmed`

Unfortunately, Android doesn't follow this pattern:
* Debug mode, `PublishTrimmed=false` for build performance, inner loop
* Release mode, `PublishTrimmed=true`

To fix this in .NET 10, we should:
* Set `PublishTrimmed=true` always
* Disable `illink` in Debug mode via other means

### Steps to Reproduce

1. `dotnet new android`
2. `dotnet build` (debug mode)
3. Observe https://github.com/dotnet/runtime/issues/109724

### Did you find any workaround?

For the case above you could set `$(_DefaultValueAttributeSupport)` as done in https://github.com/dotnet/android/pull/9525.

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.