1

There are some API tests in my solution that require setting from appsettings.json file. Local environment differs from DEV/PROD. Because of that I have main appsettings.json config and additional appsettings.Development.json with some settings specific for dev machine.

NCrunch was working fine grabbing settings from the Development config file until new configs were added:

appsettings.json
    appsettings.Development.json
    appsettings.Local.json
    appsettings.Production.json

I updated launchSettings.json file to use Local config. It works fine when I run it from VS, but NCrunch still uses Development. Is there any way to make it use Local?

Serhii Shushliapin
  • 2,528
  • 2
  • 15
  • 32

1 Answers1

1

Not tried this, but it should get you close.

  1. In Visual Studio, go to Extensions->NCrunch->Configuration
  2. Select your-project - Shared Settings (or other scope, whatever you prefer)
  3. In the bottom pane in the 'General' expander, select 'Custom environment variables'.
  4. Add a key / value as ASPNETCORE_ENVIRONMENT and Development.
Ryan O'Neill
  • 5,410
  • 4
  • 46
  • 69
  • Yep! it works! I was looking for such setting on solution/project level so that I could commit it to the repo. The setting you mentioned is in the root General Settings. Anyway, there is no need to change it often, so I think it's ok to set it manually. Thanks Ryan! – Serhii Shushliapin Jun 09 '21 at 06:29