I have this configuration in console worker service app:
IConfiguration configuration = new ConfigurationBuilder()
.SetBasePath("/home/pi/config/")
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT") ?? "Production"}.json", true, true)
.AddEnvironmentVariables()
.Build();
Which I then use with host:
IHost host = Host.CreateDefaultBuilder(args)
.ConfigureServices((cotext, services) =>
{
services.Configure<Settings>(configuration.GetSection(nameof(Settings)));
services.AddSingleton<IMyService, MyService>();
services.AddHostedService<Worker>();
})
.Build();
Then in MyService class instance, how can I get information about which config file has been used and its path? There don't seem to be any information about configuration files after injecting IConfiguration into MyService.