For Programmers: Free Programming Magazines  


Home > Archive > ASP .NET > October 2006 > RE: WEB config file deployment









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author RE: WEB config file deployment
Uli

2006-10-31, 7:06 pm

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

--
Wer nicht fragt, stirbt dumm.
If you don't ask, you'll die as a dumba**.


"SalamElias" wrote:

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

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com