json发布到不同的环境

json发布到不同的环境

本文介绍了将appsettings.json发布到不同的环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个文件appsettings.json,这是我要存储通用共享设置"的文件,然后有appsettings.Development.jsonappsettings.Production.json.

当我从Visual Studio中进行发布时,似乎只复制了appsettings.json而不是添加/合并或什至只是发送部署文件夹的简单副本,对我来说,此任务应该合并到部署管道中./p>

问题是:我该怎么办?我想念什么?难道不应该将这些动作纳入流程吗?

解决方案

请确保您的project.json具有要发布和/或复制到输出的文件列表中包含的那些文件:

"buildOptions": {
  "copyToOutput": [
    ...
    "appsettings.json",
    "appsettings.*.json",
    ...
  ],
}

"publishOptions": {
  "include": [
    ...
    "appsettings.json",
    "appsettings.*.json",
    ...
  ]
}

文件不会合并到单个文件中.它们将在运行时由配置系统进行逻辑合并.

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?

解决方案

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.

这篇关于将appsettings.json发布到不同的环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 05:08