Hi I'm trying to write environment specific configuration for specflow test and I'm a little bit confused.
I know that in .net Core i have Environment variables and in web app i can just write this:
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables();
Configuration = builder.Build();
}
But how to use this in the library class project? My Solution is divided into a main project (class library) with specflow cases, and project that will handle the connection with DB. The connection strings have to change depending on the environment. I wanted to create appsettings.{env}.Json for each, but how can I assign appsetting file depending on env if I don't have startup class?