最佳方法配置多个.NET应用程序 [英] Best Approach For Configuring Multiple .Net Applications

查看:104
本文介绍了最佳方法配置多个.NET应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一整套相互关联的.Net 3.5应用程序。有些网站,有些是网络服务,有些是Windows应用程序。每个应用程序目前拥有自己的配置文件(的app.config或web.config文件),目前还有整个配置文件中有一些重复键(这在目前保持同步手动),为多个应用程序需要相同的配置值。此外,该套件的应用程序是在不同envrionemnts(开发,测试,现场等)

We have a suite of interlinked .Net 3.5 applications. Some are web sites, some are web services, and some are windows applications. Each app currently has its own configuration file (app.config or web.config), and currently there are some duplicate keys across the config files (which at the moment are kept in sync manually) as multiple apps require the same config value. Also, this suite of applications is deployed across various envrionemnts (dev, test, live etc)

什么是从一个单一的配置源管理这些多个应用程序的配置最好的方法,这样的配置值可以在多个应用程序之间共享,如果需要的?我们也希望(部署您不必手动更改是特定的环境,如conenction字符串某些配置值时左右),有独立的configs为每个环境,但同时不希望维护多个大型配置文件(每个环境)添加新的配置键将证明麻烦时,保持这种同步。

What is the best approach to managing the configuration of these multiple apps from a single configuration source, so configuration values can be shared between multiple apps if required? We would also like to have separate configs for each environment (so when deploying you don't have to manually change certain config values that are environment specific such as conenction strings), but at the same time don't want to maintain multiple large config files (one for each environment) as keeping this in sync when adding new config keys will prove troublesome.

在此先感谢

罗宾

推荐答案

我们使用的文件,模板,如MyApp.config.template和MyWeb.config.template与恶性属性是环境之间不同的位。所以模板文件看起来有点像这样:

We use file templates such as MyApp.config.template and MyWeb.config.template with NAnt properties for the bits that are different between environments. So the template file might look a bit like this:

<MyAppConfig>
    <DbConnString>${DbConnString}</DbConnString>
    <WebServiceUri uri="${WebServiceUri}" />
</MyAppConfig>

在我们通过在南特脚本中的每个环境刚刚循环,改变了恶性性质$ {DbConnString}和$ {WebServiceUri}值的每个环境(其实这些都是生成所有的configs为不同环境构建都设置在单个​​文件中带有的每个环境部分),并做了恶性副本扩大属性接通的选项。

During a build we generate all the configs for the different environments by just looping through each environment in a NAnt script, changing the value of the NAnt properties ${DbConnString} and ${WebServiceUri} for each environment (in fact these are all set in a single file with sections for each environment), and doing a NAnt copy with the option to expand properties turned on.

我花了一些时间来获得成立,但它已经支付给我们回至少十倍的时间长度保存不同版本的配置文件乱搞。

It took a little while to get set up but it has paid us back at least tenfold in the amount of time saved messing around with different versions of config files.

这篇关于最佳方法配置多个.NET应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆