aspnet / Hosting

[Archived] Code for hosting and starting up an ASP.NET Core application. Project moved to https://github.com/aspnet/Extensions and https://github.com/aspnet/AspNetCore
Apache License 2.0
553 stars 312 forks source link

Generic Host - just how generic? #1482

Closed rynowak closed 6 years ago

rynowak commented 6 years ago

We're looking at using the generic host in Blazor - unfortunately a few aspects aren't quite generic enough for our purposes. I think it's worth looking into what things would change if we're using the generic host is in a minimal environment like WASM in the browser.

The only blocking issue I've run into so far is that the host builder creates a physical file provider, which will try to access the disk when created. https://github.com/aspnet/Hosting/blob/master/src/Microsoft.Extensions.Hosting/HostBuilder.cs#L137 This is a party foul in the browser 😢

I think long term we'd also want to replace https://github.com/aspnet/Hosting/blob/master/src/Microsoft.Extensions.Hosting/Internal/ConsoleLifetime.cs#L14


For now we're working around this by taking the code and implementing the abstractions ourselves, but it's not our desired state.

If we had the ability suppress creation of the file provider that would help.

I'm doing an experiment right now to determine what the impact is right now of adding hosting.abstractions to Blazor's in-browser set of dependencies to see what the impact is on our total dependency size. The way things are wired up in the host builder I'm not sure that we'll be able to get the linker to trim these extra dependencies.

muratg commented 6 years ago

@rynowak we would accept PRs :) Make sure to get an agreement with @davidfowl and @Tratcher though.

rynowak commented 6 years ago

Oh cool beans.

So I did finish my investigation and found that generic host brings in additional 350kb or so of dependencies, which makes it totally unsuitable for Blazor. I don't think it's realistic for us to optimize this at a level where it's useful for Blazor. Feel free to close if you don't think there's anything valuable here.

davidfowl commented 6 years ago

Agreed, we should close this out.