How to use partial config files

混江龙づ霸主 提交于 2019-12-21 12:04:16

问题


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.

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.


回答1:


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).

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



来源:https://stackoverflow.com/questions/7417062/how-to-use-partial-config-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!