20

I am trying JetBrains Rider for my existing .NET Core project. In the project I have several appsettings.json overrides:

  • appsettings.Development.json - for development
  • appsettings.Test.json - for testing
  • appsettings.Staging.json - for staging environment
  • etc.

In Visual Studio, the overrides work perfectly and I always get my Development override, when running the app in debug mode. However, in Rider I am getting the default appsettings.json values, which are not suitable for debugging and development. How do I change the settings to get the values from the correct override?

lss
  • 1,235
  • 3
  • 15
  • 24

3 Answers3

30

You'll need to set the ASPNETCORE_ENVIRONMENT environment variable.

To do this, create separate configurations for each environment:enter image description here

Then click Edit Configurations

I create one for each env - and specify the Environment variable as appropriate:enter image description here

Alex
  • 37,502
  • 51
  • 204
  • 332
  • Note that this setting in the configuration overrides the actual environment variable; I had exported it in my ~/.bash_profile but it was always reverting to Production. – aremmell Oct 12 '17 at 18:58
  • No matter what Environment Variables I set in the Run Config, it always selects appsettings.json – Tom Apr 21 '22 at 08:00
  • @Tom -- did you ever get this working? Does not work for me, I always get the main `appsettings.json` copied to output. – realmikep May 15 '22 at 22:10
  • 1
    @realmikep Yes, see my answer below: https://stackoverflow.com/a/71951660/5950725. If you're working on a shared project, it may cause colleagues issues if you check in the setting, though. – Tom May 16 '22 at 06:43
10

For the Mac interface:

  1. Choose the config you wish the to change the environment

  2. Select Environment variables

  3. Choose 'Development' or 'Production'

grg
  • 5,023
  • 3
  • 34
  • 50
Eddy Ekofo
  • 541
  • 6
  • 13
3

The accepted answer didn't work for me. I had to enter the environment variable ASPNETCORE_ENVIRONMENT=Development in to the "Runtime arguments" field:

enter image description here

enter image description here

enter image description here

Tom
  • 4,776
  • 2
  • 38
  • 50