How do I make my application use appsettings.json
on a production server, and appsettings.Development.json
on a development server?
Asked
Active
Viewed 4,986 times
1
-
Does this answer your question? [Automatically set appsettings.json for dev and release environments in asp.net core?](https://stackoverflow.com/questions/46364293/automatically-set-appsettings-json-for-dev-and-release-environments-in-asp-net-c) – jitender Jan 15 '20 at 05:31
-
I'm looking at that thread now. I think I want to be able to configure which file is used when I run "dotnet publish" ex. "dotnet publish --config Debug" or "dotnet publish --config Prod" something like that, but the --config doesn't control those files – chuckd Jan 15 '20 at 05:35
-
check this documention link https://learn.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-3.1 it specify the ways to set the environment variable – jitender Jan 15 '20 at 05:39
-
It looks like dotnet publish --configuration Release|Debug controls the appsettings.json files. Is that correct? – chuckd Jan 15 '20 at 05:47
-
Release and Debug is a different nature of information than the environment where the app is executing. A Debug build can run in Dev and QA environments, and a Release build can run in Preproduction and Production however the environments may all use their own database, so you'll need a different configuration file for each; in @jitender an answer shows how to do that with environment variables; another answer (the accepted one) shows how to do that with a flag at compilation – Guillaume S. Jan 15 '20 at 08:45