Closed davidfowl closed 1 year ago
Note on IHostingStartup
: it's used to enable various inner-loop features (i.e. in VS features during dev time). We might want to think about how we could enable those to still work during inner-loop given the app is still running on CoreCLR there, e.g. ideas:
IHostingStartup
againProgram.dev.cs
that contains a dev-time bootstrap method with a body that's behind a #if DEBUG
compiler switch that adds services required for inner-loop experiences to work, the method would be called from Progam.cs
Similar story for UserSecrets
which is only intended for use during inner-loop and is the foundation of other dev-time experiences like dotnet user-jwts
.
about routing middleware, isn't it that it's not added unless you call the map family of functions? or maybe it's only not added if you add it manually. Anyway, you also mean you don't add routing services?
@webczat
about routing middleware, isn't it that it's not added unless you call the map family of functions? or maybe it's only not added if you add it manually.
Chicken and egg problem. The Map functions are defined on the application and routing needs to be added so that they can be used.
@eerhardt It should be possible to turn on these features after the fact.
It should be possible to turn on these features after the fact.
I've updated the top proposal's Features
section to make this more explicit.
@eerhardt I still think we should do CreateEmptyBuilder
@eerhardt I still think we should do CreateEmptyBuilder
💯
Agreed. Especially now that we added stuff back to "SlimBuilder" to make it more convenient. I can open a new issue specifically for it.
I opened https://github.com/dotnet/aspnetcore/issues/48811 for CreateEmptyBuilder.
Background and Motivation
The default host builder pulls in a ton of dependencies that are rooted for trimming by default. We should have a mode where the minimal host is dependency minimal as well.
These numbers are native AOT net8.0 compiled on linx-x64:
WebApplication.CreateBuilder()
= 18.7 MBWe can stick to the current naming convention and use the existing Create/CreateBuilder methods as the one with the defaults and CreateEmptyBuilder to be the empty one:
Proposed API
API Usage
Features
When creating an "empty" web application, the following features will be on (✅) or off (❌) by default. Note that these features can be enabled by the app explicitly after creating the builder/application. They just won't be enabled by default, in order to reduce app size.
Alternative Designs
We could create whole new class names for another type of "Application" than a "WebApplication". Something like:
Other possible names include:
Risks
Potential confusion about which one to call. The template should make it obvious that the "empty" builder doesn't have anything in it, and you need to add things like appsettings, console logging, etc.