将appsettings.json发布到不同的环境

编程入门 行业动态 更新时间:2024-10-07 06:48:01
本文介绍了将appsettings.json发布到不同的环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有三个文件appsettings.json,这是我要存储通用共享设置"的文件,然后有appsettings.Development.json和appsettings.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发布到不同的环境

本文发布于:2023-11-28 03:34:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1640799.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:环境   appsettings   json

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!