Although I could be missing something, I don't see support for a Generic Host (non-web) based app, such as a fresh project using the new Worker Service template in VS 2019.
I can call UseGrace on IHostBuilder, but since there is no Startup, there doesn't appear to be a means for container registrations. For example, Stashbox.Extension.Hosting does it like this:
using (var host = new HostBuilder()
.UseStashbox()
.ConfigureContainer<IStashboxContainer>((context, container) =>
{
container.Register<Foo>();
})
.ConfigureServices((context, services) =>
{
services.AddHostedService<Service>();
})
.Build())
{
// start and use your host
}
Alternatively, it could be done similar to LightInject (with the disadvantage of not having access to HostBuilderContext which is particularly useful for access to IConfiguration)
var host = new HostBuilder().UseLightInject(r => r.Register<IBar, Bar>()).Build();
var foo = host.Services.GetRequiredService<IFoo>();
Ideally this would be in a separate nuget package, to minimize MS dependencies to only Microsoft.Extensions.Hosting.Abstractions.
Thanks, would love to investigate adopting Grace for a project, as it looks promising, but need to resolve this first.
Although I could be missing something, I don't see support for a Generic Host (non-web) based app, such as a fresh project using the new Worker Service template in VS 2019.
I can call
UseGraceonIHostBuilder, but since there is noStartup, there doesn't appear to be a means for container registrations. For example, Stashbox.Extension.Hosting does it like this:Alternatively, it could be done similar to LightInject (with the disadvantage of not having access to
HostBuilderContextwhich is particularly useful for access toIConfiguration)Ideally this would be in a separate nuget package, to minimize MS dependencies to only
Microsoft.Extensions.Hosting.Abstractions.Thanks, would love to investigate adopting Grace for a project, as it looks promising, but need to resolve this first.