public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .UseWindowsService() //https://csharp.christiannagel.com/2019/10/15/windowsservice/ .ConfigureAppConfiguration((hostingContext, config) => { config.AddJsonFile($"{AUTOUPDATER_PROCESS_EXEC}.json"); }) .ConfigureServices((hostContext, services) => { IConfiguration configuration = hostContext.Configuration; WorkerOptions workerOptions = configuration.GetSection("WorkerOptions").Get <WorkerOptions>(); services.AddSingleton(workerOptions); DeploySettings deploySettings = configuration.GetSection("DeploySettings").Get <DeploySettings>(); services.AddSingleton(deploySettings); services.AddSingleton <Informer>(); services.AddHostedService <Worker>(); });
public Informer(ILogger <Informer> logger, WorkerOptions workerOptions, DeploySettings deploySettings) { _logger = logger; _workerOptions = workerOptions; _deploySettings = deploySettings; }