If we can have more than one .config files, we can share one config file with other projects and put private configuration into another. Visual Studio 2008 will be confused?
You can have multiple web config for each directory although only one config section handler.
No, except for the <appSettings>
node which has a special file=
attribute which works in a "cummulative" manner, all configuration sections are single shot affairs - you have it, and you have one of it exactly - or you have nothing.
<appSettings file="common.appsettings.config">
<add key="private1" value="value1" />
</appSettings>
This will read in the contents of the common.appsettings.config
file and anything that's not being overwritten by an explicit value in your own config here is being used from that external config file.
You cannot add additional "private" info to an existing configuration section, as far as I know.
Hi,
Visual Studio 2010 has support for multiple .config files. It is one feature of new web application packaging and deployment system. We can create now separate web.config files for each configuration we have for application. But for 2008 there are no support for multi config files, you can workaround this by adding two config files and rename them in build time
Example:
private.config public.config
on pre-msbuild event merge these two files
rename merged file, it should be web.config or app.config
Hope this helps...
The configuration files are hierarchical from general to specific. Configuration files further down in the hierarchy override any settings from the previous ones. So if you have a solution that includes a master web.config file, any web.config files in your projects override it and are specific and visible only to those projects. If a project is comprised of several folders, you can add a web.config file to each of those as well, again with different settings that also override any of those set above. But I caution over-engineering this or you may have difficulty with a trickle-down of certain property values or loopholes in security if it is security that you are configuring at each level.
In theory, you should be able to have multiple .config
files, some of which would be shared by several projects.
One way of doing it is employing some utility that is able to merge two XML files that have the same basic structure. You could then add a pre-built or post-build event that calls this tool. The tool would then merge several .config
files and output the resulting .config
file to the project's target directory.
If you don't want to rely on any external tool and get this done purely in Visual Studio, you might not find any practical solution.