I deploy a .NET 6 console app to multiple environments (Dev, Staging, Production).
In ASP.NET hosted applications, I can set the ASPNETCORE_ENVIRONMENT value, so that an additional appsettings.{Staging}.json file is read in. Is there an equivalent way I can specify the environment from the command line for the console app? I do not want to modify the system-wide environment variables on the host machines but am considering using a batch file.
I want to do something like
dotnet mydotnetconsoleapp.dll --environment=Staging
then it should read in appsettings.Staging.json I read that --environment should work but I think am doing something wrong.
I am on Windows.