如何使用部分配置文件 [英] How to use partial config files

查看:78
本文介绍了如何使用部分配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我参与了一个在不同位置进行开发和测试的项目。 app.config中有一些条目位于不同位置的本地(因此为 config)。因此,每个人都倾向于保留自己的app.config,这总是很难引入新的设置。

I am involved in a project where development and testing is going on in different locations. There are a few entries in the app.config that are "local" to the different locations (hence, "config"). Therefore, everyone tends to keep his own app.config, which always makes it difficult for a new setting to be introduced.

我正在寻找一个想法,例如局部类,其中app.config的大部分可以放在一个地方,少数几个地方在另一个地方,但是在构建之后,所有这些都在正确的exe.config中结束。

I'm looking for an idea, something like partial classes, where the bulk of an app.config can be in one place, and a few items in another, and yet all wind up in the proper exe.config after a build.

推荐答案

首先,您可以使用 configSource 属性拆分配置文件。例如,在web.config中,您可以编写:

First of all you can split up config file using the configSource attribute. For example, in web.config you could write:

    <authentication configSource="ConfigFiles\authentication.config" />

..并将您的身份验证配置保存在另一个文件中。

.. and have your authentication config in another file. This may be of use to you, with local variations (eg. DB settings).

第二,更重要的是,您可能想观看此视频以了解有关部署的信息。到不同的环境(使用 web.debug.config web.release.config

Secondly, and more importantly, you probably want to watch this video to learn about deploying to different environments (using web.debug.config and web.release.config)

http://www.hanselman.com/blog/WebDeploymentMadeAwesomeIfYoureUsingXCopyYoureDoingItWrong.aspx

这篇关于如何使用部分配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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