C# 堆叠app.config文件,多层嵌套不会';好像不行
我希望以与web.config文件工作方式类似的方式来堆叠app.config文件 我真的想进入以下层次结构C# 堆叠app.config文件,多层嵌套不会';好像不行,c#,app-config,C#,App Config,我希望以与web.config文件工作方式类似的方式来堆叠app.config文件 我真的想进入以下层次结构 machine.config (nice and clean no extra config) Environment config (in source control shared by everyone) app.config/web.config (config at a non-environmental application lev
machine.config (nice and clean no extra config)
Environment config (in source control shared by everyone)
app.config/web.config (config at a non-environmental application level)
Developers hack config (overrides all the things)
我已经了解了使用file
或configSource
属性的节继承(请参阅:)
然而,举例来说,我似乎找不到任何方法来堆积这些超过一层的深度
static void Main(string[] args)
{
Console.WriteLine("Setting1: {0}", ConfigurationManager.AppSettings["setting1"]);
Console.WriteLine("Setting2: {0}", ConfigurationManager.AppSettings["setting2"]);
Console.WriteLine("Setting3: {0}", ConfigurationManager.AppSettings["setting3"]);
}
app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings file="tier1.config">
<add key="setting1" value="yay"/>
</appSettings>
</configuration>
tier1.config
<?xml version="1.0" encoding="utf-8" ?>
<!--appSettings file="tier2.config"--><!-- using this gives the following: Unrecognized attribute 'file'. Note that attribute names are case-sensitive. -->
<appSettings>
<add key="setting2" value="yay"/>
</appSettings>
tier2.config
<?xml version="1.0" encoding="utf-8" ?>
<appSettings>
<add key="setting3" value="yay"/>
</appSettings>
有没有一种方法可以使用file属性或其他方法来获得多个级别(多于2个)的配置继承?您可以使用Slowcheetah
我们使用slowcheetah有一段时间了,它是一堆乱七八糟的东西,我们构建了太多的应用程序,因此它不是一个合适的解决方案。每个应用程序中的每个项目都需要为每个环境进行构建配置,这是一个需要管理的噩梦,也意味着我们有大量的配置文件。我们使用机器配置进行环境配置,但这也不太好。