How to use partial configuration files

I participate in a project where development and testing are carried out in different places. There are several entries in app.config that are "local" in different places (hence, "config"). Therefore, everyone wants to keep their own app.config, which always makes it difficult to enter a new setting.

I am looking for an idea, something like partial classes, where the main part of app.config can be in one place, and several elements in another, and yet everything ends in the correct exe.config after building.

+6
source share
1 answer

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

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

.. and enter your authentication configuration in another file. This may be useful to you, with local options (e.g. DB settings).

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

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

+9
source

Source: https://habr.com/ru/post/897317/


All Articles