Description
Describe the bug
When running, debugging or deploying Asp.Net Core applications, environment variables are added to the web.config file, which ultimately concatenates this specific environment variable, rendering it absolutely worthless. For example, if you set the environment variable to 'Development', running or debugging the application causes the environment variable to be rendered as 'Development;Staging', 'Development;Development', 'Staging;Production', or some variation thereof. This makes determining which Startup class, Config class and appSettings.json file impossible to determine at run time.
To Reproduce
Steps to reproduce the behavior:
- Start with a normal Asp.Net core application running in IISExpress.
- Set a system environment variable for ASPNETCORE_ENVIRONMENT.
- Add a profile to allow running the application through the local machine's IIS.
- Run or debug the project. <-- at this point, you can see the web.config has been mondified
- Remove the local IIS profile and run/debug/deploy again.
- Condition persists.
- Remove the IIS application definitions from the local IIS and repeat.
- Condition persists.
The web.config file will be modified to include the environment variable ASPNETCORE_ENVIRONMENT.
Expected behavior
With so many different ways to set the environment variable, I would expect the web.config file to NOT be modified with the environment variable. This completely breaks the application.
Visual Studio Version
Visual Studio 2019 version 16.2.1