How to add a minmal Webhost to a HostApplicationBuilder
#54418
Unanswered
MarcusWichelmann
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Would |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I'm building a CLI tool and use
Host.CreateEmptyApplicationBuilder
to configure a simple, emptyHostApplicationBuilder
with just some console logging and dependency injection. This works fine. I really don't need much for this application.Now, for a single CLI command (one of many), I want to host a gRPC service. For this, I need to use ASP.Net Core. But I don't find a way to add a minimal Kestrel instance to my
HostApplicationBuilder
.I don't want to use
WebApplication.CreateBuilder
to create a whole newWebApplicationBuilder
because I'd have to add my dependencies again to that builder which would duplicate and complicate things. And I also cannot useWebApplicationBuilder
for all cli commands, because this automatically registers someIHostedService
s that I don't want to run with each command.What I'm searching for: A way to add just the few dependencies I need for a Kestrel web server with gRPC support to an existing empty
HostApplicationBuilder
. I'd prefer a manual & declarative approach where I can explicitly decide myself, which services I want to include, because I don't need most of the things ASP.Net Core brings by default and want so safe some memory. IMHO, the defaultWebApplicationBuilder
does way to much implicit magic that is hidden away in someinternal
classes that cannot be partially reused.Do you have an idea, how this can be archieved?
Beta Was this translation helpful? Give feedback.
All reactions