Skip to content

Microsoft.NET.Sdk.Web should default to TrimMode=full #30059

Closed
@eerhardt

Description

@eerhardt

Today, we are defaulting TrimMode=partial in Microsoft.NET.Sdk.Web:

<!-- If TrimMode has not already been set, default to partial trimming, as AspNet is not currently fully trim-compatible -->
<TrimMode Condition="'$(PublishTrimmed)' == 'true' and '$(TrimMode)' == ''">partial</TrimMode>

    <!-- If TrimMode has not already been set, default to partial trimming, as AspNet is not currently fully trim-compatible -->
    <TrimMode Condition="'$(PublishTrimmed)' == 'true' and '$(TrimMode)' == ''">partial</TrimMode>

In the "api" template being added in dotnet/aspnetcore#46064, we are explicitly setting TrimMode=full.

Instead, we should do one of the following:

  1. Remove the above code, and just let the TrimMode=full default from the runtime be applied to Microsoft.NET.Sdk.Web projects.
  2. Change the default to partial only if we aren't also publishing for NativeAOT. Basically adding and '$(PublishAot)' != 'true' above.

My goal would be we do (1). For places in ASP.NET that aren't fully trim-compatible, the app developer should get a warning (even from within ASP.NET code) to tell them what are things that aren't going to work.

We may consider just doing (2) in .NET 8, until things like MVC and Razor pages work correctly in fully trimmed apps.

cc @JamesNK @DamianEdwards @davidfowl

Metadata

Metadata

Labels

Area-AspNetCoreRazorSDK, BlazorWebAssemblySDK, dotnet-watch

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions