Skip to content

[.NET 10] change default value for PublishTrimmed #9526

Description

@jonathanpeppers

Android framework version

net9.0-android

Affected platform version

any

Description

Context: #9525
Context: dotnet/runtime#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 RuntimeInstanceNotAllowed Error Initializing XmlSerializer on Android Release Build in .NET 9 runtime#109724

Did you find any workaround?

For the case above you could set $(_DefaultValueAttributeSupport) as done in #9525.

Activity

  1. added
    Area: App+Library Build
    on Nov 19, 2024
  2. added this to the .NET 10 milestone on Nov 19, 2024
  3. added
    needs-triage
    on Nov 19, 2024
  4. removed
    needs-triage
    on Nov 20, 2024
  5. added
    enhancement
    on Jan 21, 2025
  6. added theissue type on Apr 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Area: App+Library Buildenhancement

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions