.netdockerrider

Use EnvironmentVariables in launchsettings.json in Rider Docker configuration


I'm working on a team where some people use VisualStudio, and others use Rider. We've recently dockerized our application, and we're able to run the app just fine in VisualStudio with the following launchsettings.json.

{
  "profiles": {
    "MyApp - Project: {
      "commandName": "Project",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "testing"
      },
      "applicationUrl": "https://localhost:57787;http://localhost:57788"
    },
    "MyApp - Docker": {
      "commandName": "Docker",
      "launchBrowser": true,
      "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "testing"
      },
      "sslPort": 5003,
      "httpPort": 5002
    }
  }
}

When we run this in VisualStudio, we end up successfully getting the environment variable set to testing.

However, when we're trying to get our Rider users setup, we get an incorrect environment variable - Development.

I know that I could drop the Environment Variables into the configuration itself, like below, but we have a number of other environment variables on our launchSettings.json that get automatically generated each morning, so I really need this to work like it does in VS, where the Environment Variables come in on the LaunchSettings.json and get read from there into the Docker container.

enter image description here

I also know that if I run it under my other PR using the .NET Launch Settings Profile, it DOES read from the launch settings...

Is there any way to make Rider work where it uses the LaunchSettings to both run the Docker image AND attach the associated Environment Variables?


Solution

  • Rider is not fully compatible with the Docker configuration in launchSettings.json at the moment. See this ticket for details:

    RIDER-104672 Docker run launch profile showing as incorrect

    Manage your Docker configurations in .run could be the best solution here.