WEB config file deployment

G

Guest

Hi, I am confornted with a problem regarding web.config file. I have 4
environements (Dev, Test, staging and production). The IT people need
wgenever a new MSI delivered to have the right environment keys in there
sections and not the dev machines web config. What I mean by that I don't
want the IT people to edit the web config for each environement manually. Is
there any baset practices or patterns to automatically deploy goof web.config
files.
I use TFS for nightly builds and thinking of implememnting TFS a s the tool
which should be used by IT people to get delivarables in order to deploy them
instead of filling special froems and using files shares for delivarables.
Of course, I know that we can exclude the web.config from the msi and every
delivery people go and update manullay the file in another environment but I
dont want that either if possible of course.
Thanks.
 
G

Guest

If you can keep your settings in the appSettings section, it has a "file="
optional attribute to specify a separate file from which the appSettings
section will be loaded, overwriting keys present in the original having the
same names.
Peter
 
G

Guest

Hi,

here is the way I'm doing it.

Set a machine identity in the machine.config that says if it is a
development, stage or production server (e.g. d, s or p. It might be good to
add an "l" for local also).

for the Development-server
<add key="ApplEnv" value="d" />


Then you can put the connection strings for all environments into the
web.config

<add key="ConnectionString-l" value="server=(local);......."/>
<add key="ConnectionString-d" value="server=DEV-Server;......"/>
<add key="ConnectionString-s" value="server=STG_Server;....."/>
<add key="ConnectionString-p" value="server=PRD-Server;....."/>

In your code put something like:

private static string DbConnectionString
{
get
{
string strApplEnv = ConfigurationSettings.AppSettings["ApplEnv"];
string paramSuffix = strApplEnv.ToLower().Substring(0,1);
return ConfigurationSettings.AppSettings["ConnectionString-" +
paramSuffix] ;
}


This way you can use the web.config for all environments.

Regards,
Uli
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top