When you start the application Visual Studio will automatically set the environment variables for you (based on settings from launchSettings.json in the properties folder).

When you run from commandline or double-click, you need to set the environment variable yourself using setx ASPNETCORE_ENVIRONMENT "Development" (Commandline) or $Env:ASPNETCORE_ENVIRONMENT = "Development" (Powershell).