Web Deployment Projects and deploying web.config settings for multiple machines

I wrote the following comment on a post http://weblogs.asp.net/dfindley/archive/2006/06/06/Frustrations-with-Web-Deployment-Projects.aspx about having machine dependent configurations in your web.config. DFindley expresses some frustrations with the web deployment projects on configuring per machine settings in the web.config, but he found the fix right away. This approach is powerful, but sometimes not clear where the settings are actually managed. I use another approach that works quite well for me. I posted this as a comment on the mentioned post.

Scott mentions in his comment to have a web.config per machine, and copy the correct web.config on deployment.
I prefer to only have replacements for the changing sections per machine. Often these settings are the appSettings, connections and an impersonation account.
In this approach you can manage the other settings in a generic web.config that is used for all machines.
So what I do is the following:

Create appSettings files per machine:

MACHINE1.appSettings.config
MACHINE2.appsettings.config

Create connections files per machine:

MACHINE1.connections.config
MACHINE2.connections.config

On automated deployment check your machine name, and copy:

MACHINEX.appSettings.config to appSettings.config
MACHINEX.connections.config to connections.config

In your web.config you refer to those external files as follows:

<appSettings configSource="appSettings.Config"/>
<connectionStrings configSource="connections.config"/>

Another thing you often want to set is the impersonation account, we manage those in the registry per server in a secure way as follows:

<!-- Impersonation identity is encrypted in the registry. Identity is set with the following command:
   
aspnet_setreg.exe -k:SOFTWARE\MyApp\identity -u:"yourdomainname\username" -p:"password"
   
Tool can be downloaded at:
  
http://download.microsoft.com/download/2/9/8/29829651-e0f0-412e-92d0-e79da46fd7a5/aspnet_setreg.exe
-->
<identity impersonate="true"
          userName="registry:HKLM\SOFTWARE\MyApp\identity\ASPNET_SETREG,userName"
          password="registry:HKLM\SOFTWARE\MyApp\identity\ASPNET_SETREG,password" />

Published Wednesday, June 07, 2006 9:41 AM by svdoever
Filed under: ,

Comments

Wednesday, June 07, 2006 12:37 PM by David Findley's Blog

# Web Deployment Project frustration turning to enlightenment.


Thanks to some great suggestions by Scott and others I have put aside any fears/laziness of delving...
Tuesday, December 19, 2006 11:45 AM by sunilprabha

# re: Web Deployment Projects and deploying web.config settings for multiple machines

good one , but where todeploy MACHINE1.appSettings.config on the physical drive on the server .

Tuesday, December 19, 2006 5:53 PM by Serge van den Oever

# re: Web Deployment Projects and deploying web.config settings for multiple machines

What I do is that I deploy them to the folder where appSettings.config should end up, after deploying them there I check which of the MACHINE.appSettings.config files must be copied to appSettings.config, I do the copy, and cleanup the others.

Friday, October 26, 2007 3:13 AM by Utku Selamoglu

# re: Web Deployment Projects and deploying web.config settings for multiple machines

Thanks a lot. This information helps me so much..:)

Leave a Comment

(required) 
(required) 
(optional)
(required)