Skip to content

ASPNETCORE_ENVIRONMENT issues with Startup classes and local IIS profiles #14919

Open
@echuck66

Description

@echuck66

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:

  1. Start with a normal Asp.Net core application running in IISExpress.
  2. Set a system environment variable for ASPNETCORE_ENVIRONMENT.
  3. Add a profile to allow running the application through the local machine's IIS.
  4. Run or debug the project. <-- at this point, you can see the web.config has been mondified
  5. Remove the local IIS profile and run/debug/deploy again.
  6. Condition persists.
  7. Remove the IIS application definitions from the local IIS and repeat.
  8. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    affected-very-fewThis issue impacts very few customersarea-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsbreaking-changeThis issue / pr will introduce a breaking change, when resolved / merged.enhancementThis issue represents an ask for new feature or an enhancement to an existing oneseverity-nice-to-haveThis label is used by an internal tool

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions