Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JetBrains Rider - configure appsettings overrides

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?

like image 238
lss Avatar asked Aug 08 '17 11:08

lss


People also ask

How do you add environment variables in rider?

Add environment variablesFrom the main menu, select Run | Edit Configurations or choose Edit Configurations from the run/debug configurations selector on the toolbar. In the Run/Debug Configurations dialog, select a configuration where you want to add the environment variables.

What is launchSettings JSON used for?

launchSettings. json, which is placed in the Properties folder of a project, describes how the application can be launched — the command to execute, whether the browser should be opened, which environment variables should be set, and so on.

How do you set an environment variable in the NET Core console app?

With all these packages installed, I could initialize the ConfigurationBuilder with a subset of the default ASP.NET Core setup: var environment = Environment. GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); var builder = new ConfigurationBuilder() . AddJsonFile($"appsettings.


1 Answers

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

like image 71
Alex Avatar answered Sep 24 '22 21:09

Alex