launchSettings.json not used by Rider
I am switching to Rider from Visual Studio as my IDE recently and I have faced this situation where Rider is not picking up environment variable from launchSettings.json
. I would like to share what I learnt.
Issue
I realized something was wrong while debugging my app where my configurations from appsettings.Development.json
were not being picked up. After some chasing, I discovered the issue was caused by EnvironmentName
being Production
.
However, my launchSettings.json
had the environmentVariables
"DOTNET_ENVIRONMENT": "Development"
. It appears to me that Rider is not using the launchSettings.json
.
Solution
Turns out, I learnt that Rider has its own run/debug configuration. Normally, it should choose the configuration with launch profile coming from launchSettings.json
. However in my case, it somehow default to a different configuration, which does not take variables from launchSettings.json
. The solution is to select the correct debug configuration (the one with the rocket).
I also deleted the other configuration as well because I don’t need that.
Conclusion
I hope this may help you if you have faced the same issue in Rider. I am still new to Rider and I will share my experience and any tips or tricks as I go.