I have three files appsettings.json
which is a file that I want to store "general shared settings", then I have appsettings.Development.json
and appsettings.Production.json
.
When I do a publish from Visual Studio, it seems like only appsettings.json
is copied and not adding / merge or even just send a simple copy the deployment folder, to me this task should be incorporated into the deployment pipeline.
The question is: how can I do it? What am I missing? Is it not supposed that these actions should be already be incorporated in the process?
Of course, we can add and use multiple appsettings. json files in ASP.NET Core project. To configure and read data from your custom json files, you can refer to the following code snippet.
NET Core and as far as I see from my search on the web, appsettings.Development. json is used for development config while developing the app and appsettings. Production. json is used on the published app in production server.
Make sure your project.json
has those files included in the list of files to publish and/or copy to output:
"buildOptions": {
"copyToOutput": [
...
"appsettings.json",
"appsettings.*.json",
...
],
}
or
"publishOptions": {
"include": [
...
"appsettings.json",
"appsettings.*.json",
...
]
}
The files will not be merged in a single file. They will be logically merged at runtime by the configuration system.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With