Publishing appsettings.json to different environment

只谈情不闲聊 提交于 2019-12-12 12:16:27

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/38710269/publishing-appsettings-json-to-different-environment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!