ConsoleAppFramework icon indicating copy to clipboard operation
ConsoleAppFramework copied to clipboard

Make ConsoleAppBuilder implement IHostApplicationBuilder.

Open willnationsdev opened this issue 3 weeks ago • 1 comments

A fair number of packages nowadays only provide public registration mechanisms for IHostBuilder or its modern equivalent, IHostApplicationBuilder. For example, I wanted to try adding a RazorConsole GUI to my console app if no arguments were given, but I was unable to integrate it for that reason. As far as I can tell, it should theoretically be possible to do, but I'm not sure how much of a headache that would be since CAF uses source generation pretty heavily and doing so would open up the possibility of other packages contributing service registrations, logger building, configuration building, etc. that isn't part of the established builder methods (so I imagine it would be fairly difficult). If so, then just dismiss this as a wontfix.

If I were really that desperate, I could always just inline instantiate a new host application builder and run it within the root command implementation, even if it looks a bit silly.

willnationsdev avatar Dec 12 '25 21:12 willnationsdev

RazorConsole appears to be built on top of BackgroundService, so just implementing IHostApplicationBuilder won't be meaningful. In ConsoleAppFramework's IHost integration, the Host itself does Start. Anything beyond that level of coordination is, I think, unrelated to this framework.

neuecc avatar Dec 14 '25 11:12 neuecc

Gotcha. So in this case, you'd recommend a solution that involves getting in touch with the other framework and asking them to expose a method that registers necessary services with an IServiceCollection extension method, rather than exclusively exposing its API through the host/app stuff. Makes sense.

willnationsdev avatar Dec 18 '25 18:12 willnationsdev