Minimal reproduction project for "Unprefixed Hosting Environment Variable is ignored"
- Create a new web project
dotnet new web
- Run it setting "ENVIRONMENT" environment variable
export ENVIRONMENT=Repro && dotnet run
- Search the logs for
Hosting environment:
Expected | Actual |
---|---|
Hosting environment: Repro | Hosting environment: Development |
I was leaning toward assuming that the variable is ignored since it's overridden by launchSettings
. But first, deleting launchSettings
doesn't make a difference in the problem (only changing Development to Production). And for other variables unprefixed variables take precedence over variables prefixed with ASPNETCORE_