asp.net-core.net-core.net-core-3.1ncrunch

How to make NCrunch use specific appsettings.json file?


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?


Solution

  • 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.