Frustrations with Web Deployment Projects

Web deployment projects are an elegant way of integrating the compilation of an asp.net web site into a build process. I was initially really impressed with the msbuild task that replaces sections of your web.config at build time. Unfortunately  this feature is starting to dissapoint. As this forum post points out it is fairly limited in scope as to what sections it can modify. I recently tried getting the deployment project to update the system.net/mailSettings section. I have yet to get it to modify this section. The build will just fail saying that it cant find system.net/mailSettings. This shouldnt be this hard. I hope I'm totally missing something and the rest of this post can just be ignored.


Ok, Im the moron on this one. under is a group not a config section as I orginally thought. Once I changed the deployment project to this:

system.net/mailSettings/smtp=mailSettings.config;

It worked like a champ.

So the moral of this story is check, double check and triple check what type of node you are trying to replace in the deplyment project.

I'm still not sure why it matters what type of node you are replacing.

Update: Some good ideas here for more advanced scenarios.
Published Tuesday, June 06, 2006 6:31 PM by findleyd
Filed under:

Comments

# re: Frustrations with Web Deployment Projects

Tuesday, June 06, 2006 8:17 PM by ScottGu
One other option to consider with web deployment projects is to have a separate web.config file for each deployment type (development, test, release).  You could have them in your web project like so:

dev-web.config
test-web.config
release-web.config

You could then have your web deployment project overwrite the web.config that is used with the appropriate build based on your build settings.

Hope this helps,

Scott

# re: Frustrations with Web Deployment Projects

Tuesday, June 06, 2006 9:29 PM by findleyd
Good suggestion. I was thinking of something like that as well. But in this particular case there are just a couple of places that need changes so the replacement stuff is working pretty well. (Now that I pulled my head out)

# re: Frustrations with Web Deployment Projects

Wednesday, June 07, 2006 3:41 AM by svdoever
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 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:

MACHINE1.appSettings.config
MACHINE2.appsettings.config

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\KPMG\AMT\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" />

I think that all of this is ASP.NET 2.0 functionality.

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

Wednesday, June 07, 2006 3:52 AM by Serge van den Oever [Macaw]
I wrote the following comment on a post http://weblogs.asp.net/dfindley/archive/2006/06/06/Frustrations-with-Web-Deployment-Projects.aspx&amp;nbsp;about...

Leave a Comment

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