DOTNETENVIRONMENT
DOTNET_ENVIRONMENT is an environment variable used by the .NET runtime and hosting infrastructure to designate the environment in which an application is running. The value exposed by this variable is typically exposed to the app as IHostEnvironment.EnvironmentName, influencing how configuration and behavior are applied during startup and execution.
This environment name governs loading of environment-specific configuration files, such as appsettings.{EnvironmentName}.json, and can affect code
In practice, ASP.NET Core projects often rely on a related variable, ASPNETCORE_ENVIRONMENT, to set the environment
- Windows (PowerShell): $env:DOTNET_ENVIRONMENT = "Development"
- Windows (cmd): set DOTNET_ENVIRONMENT=Development
- Linux/macOS: export DOTNET_ENVIRONMENT=Development
If DOTNET_ENVIRONMENT is not set, the default environment name is Production. Changing the value affects configuration