How to set ASPNETCORE_ENVIRONMENT to be considered for publishing an ASP.NET Core application
Asked 07 September, 2021
Viewed 854 times
  • 46
Votes

When I publish my ASP.NET Core web application to my local file system, it always takes the production-config and the ASPNETCORE_ENVIRONMENT variable with the value = "Production".

How and where do I have to set the value of the ASPNETCORE_ENVIRONMENT variable so that it will be considered not only for debugging, but also for the publishing? I already tried the following options without success:

  • in windows settings
  • in file .pubxml file
  • in file launchSettings.json
  • in file project.json

14 Answer