Skip to content

ApplyWebConfigModifications for only one webapplication

June 2, 2011

Our goal was to create a simple command line tool to set several web.config settins during deployment. SPWebConfigModification appeared to be a good tool for it as it takes care of applying the changes to all front end servers in a multi-server farm. We were however unable to tell it that apply the web.config changes to only one web application and don’t touch the config files of the SSP and Central Admin.

We tried all approaches suggested in blogs, forums but none of them helped.

So finally we just did the following:

  1. backup all the web.configs
  2. run our command line tool
  3. restore the web.configs, except the one that we wanted to update

This is the command we used to backup the web.config

xcopy /s C:\inetpub\wwwroot\wss\VirtualDirectories\*.config c:\BACKUP

And this is how we restored them after the web.config update:

ren c:\BACKUP\80\web.config web.config.tmp
xcopy /s /Y  c:\BACKUP\*.config %IISROOT% 
ren c:\BACKUP\80\web.config.tmp web.config

(the file that we wanted actually to update had to be renamed so that the changes won’t get overwritten)

Of course, the script needs to be run on all web frontends while the tool must be run only on one of them.
Ugly solution but seems to work so far. Any other solution however is highly welcome…

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: