gpt4 book ai didi

c# - 在项目之间合并 web.configs

转载 作者:可可西里 更新时间:2023-11-01 08:11:25 24 4
gpt4 key购买 nike

我有一个通用的 Web 项目,用作多个“子”Web 项目的基础。是否可以在项目之间应用 web.config 转换/合并?假设结构如下所示:

base project
- web.config

child project
- web.config
- transform.config

是否可以进行预构建事件或类似事件,将基础项目 web.config 与子项目 web.config 合并?

最佳答案

您可以编辑到单独的文件 (transform.config) [1] , [2] 和:

Add an <appsettings> section and add your data as key/value pairs of the form:

<add key="xxx" value="xxxx" />

That's all to create new app.config file with settings in it.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Child1" value="Child1_Value" />
<add key="Child2" value="Child2_Value" />
</appSettings>
</configuration>

连接字符串也是如此 [3] :

<connectionStrings>
<add name="yourConnectionStringName"
connectionString="yourConnectionString"
providerName="System.Data.SqlClient"/>
</connectionStrings>

并使用 configSource对于父文件:

<connectionStrings configSource="parentWeb.config"/>

关于c# - 在项目之间合并 web.configs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48061900/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com