-
Notifications
You must be signed in to change notification settings - Fork 10.3k
(NET 9) MapControllers() don't work with option PublishTrimmed = true #58926
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
MVC doesn't support trimming: #41767 #27384 (comment) If it worked in previous releases for your application, that was just a happy accident. |
Yes If I change it to
Then everything will work. And on NET 8 it greatly reduced the build size. I'm sad to lose that feature in the new 9 version. |
Wow, 1 day of no activity and issue closure. Better not file issues on Friday. |
I assume the MVC assemblies are not marked as supporting trimming? In which case this project property should still work:
And why was this closed after a day? This smells like a regression, as I can reproduce the problem with the above project property, which should disable trimming on any assembly not explicitly opting in to trimming. |
AFAIA, it working before was a happy accident. It wasn't, and still isn't, a supported scenario. |
The bigger concern goes beyond MVC trimming support: this appears as a defect with the I'm disturbed this isn't being taken more seriously. |
Using I believe this ticket should be reopened, this is a regression, not a "happy accident" |
I also think this is a bug. The code from the first message works great in the previous versions of the framework (net 7,8). Or this problem should be announced in the "breaking change net 9" section. |
I used this "happy accident" for several years. Previously, I created Docker images with net 8 application with controllers (PublishTrimmed = true, TrimMode = partial, SelfContained = true). I made images on pure Alpine without NET runtime. The images size was about 28 megabytes. Now the trimming does not work. I have to not use the SelfContained option. Now I will disgrace in front of our devops engineers with an image of 58 megabytes due to upgrade on NET 9. 😅 It was cool feature 😔 |
@davidfowl I'd love to hear your thoughts on this and whether this "happy accident" is a regression, and whether the |
Partial trim mode is definitely a happy accident. AFAIK we don't even default to partial trim mode anymore, but left it in for those that happened to be using it successfully. |
If this is an intentional breaking change, it ought to be called out in the breaking changes of the .NET 9.0 release notes, otherwise people will assume it was an unintentional regression. I am still concerned about the overall state of partial trim mode support beyond ASP.NET--are we 100% sure partial trim mode works as expected beyond ASP.NET? Is partial trim mode going to be supported in .NET 10? https://learn.microsoft.com/en-us/dotnet/core/compatibility/9.0#aspnet-core |
@davidfowl Hey, David! If partial trimming worked in the previous version(net 7-8), but does not work in the new one(net 9), then this is a breaking changes. Do you disagree? |
The breaking change is documented https://learn.microsoft.com/en-us/dotnet/core/compatibility/aspnet-core/8.0/trimmode-full |
So if you use trim mode full in an asp.net project it should work fine? It's just partial that's busted? |
Is there an existing issue for this?
Describe the bug
Hello!
I have a problem with migration from NET 8 to 9.
System.NotSupportedException: 'IsConvertibleType is not initialized when
Microsoft.AspNetCore.Mvc.ApiExplorer.IsEnhancedModelMetadataSupported
is false.'This code work well on NET 8, but on NET 9 dont work .
Is this a breaking change or a bug?
Steps To Reproduce
Program.cs
HomeController.cs
WebApplication1.csproj
If I don't use the option PublishTrimmed, then everything is fine. But I need it for compact deployment with SelfContained.
.NET Version
9
The text was updated successfully, but these errors were encountered: