Closed
Description
Today, we are defaulting TrimMode=partial
in Microsoft.NET.Sdk.Web
:
sdk/src/WebSdk/Publish/Targets/Microsoft.NET.Sdk.Publish.targets
Lines 89 to 90 in 67b5915
<!-- 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:
- Remove the above code, and just let the
TrimMode=full
default from the runtime be applied to Microsoft.NET.Sdk.Web projects. - Change the default to
partial
only if we aren't also publishing for NativeAOT. Basically addingand '$(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.