Tutorial :Deploying application updates to multiple sites


I have an application consisting of an ASP.NET web application, a couple of Windows services, and a SQL Server 2005 database. This application is replicated at several sites, so that each site has a server containing all parts (web app, services, & DB). Currently the process for deploying updates is this:


  1. Script database changes (using Generate Scripts in Management Studio).
  2. Connect to a site's DB in Management Studio.
  3. Run SQL script on site's DB.
  4. Repeat 2 & 3 for each site.

Web Application

  1. Use Publish in Visual Studio.
  2. Delete web.config from published copy.
  3. Zip web application files.
  4. Copy zip file to a site.
  5. Remote desktop into that site to unzip files.
  6. Manually modify web.config when necessary.
  7. Repeat 4-6 for each site.

Windows Services

  1. Build project in Visual Studio.
  2. Zip rebuilt binaries.
  3. Copy zip file to a site.
  4. Remote desktop into that site.
  5. Stop the service.
  6. Uninstall the old version.
  7. Install the new version.
  8. Manually modify the .config when necessary.
  9. Start the service.
  10. Repeat 3-9 for each site.

Currently there are 3 sites and deployments are annoying but manageable, however within the year we will most likely have 10 or 11 sites and having to deploy updates this way would make me suicidal.

So, I am looking for suggestions on how to automate this process. I have started looking into learning MSBuild for merging configurations and copying files out to my servers, but I'm not sure how far it will take me. Thanks.


Take any script language you are comfortable with (looks like even .bat would work for you) and get PsTools

You can then use psexec and psservice to control processes and services remotely. You'll still have to write the scripts yourself but you won't have to login remotely (eg. to unzip and copy the files) and what works for one server will work for 10.


MSBUILD can pretty much do all you need. But it sounds like you would need some custom tasks to do it completely automated. But it is possible with a little effort.

MSBUILD is actually already apart of your project. It is the project file itself. It basically is XML behind everything. And in this XML there are PreBuild and PostBuild events that get fired and you can essential do copy, paste commands and the like.

Also you might be interested in Web Deployment projects that allow you to have multiple web.config files for each enviroment you are building to.

For more advanced scenarios you can create your own custom tasks that integrate with MSBUILD's events. You can even use conditions with these tasks. The reference below talks all about it.

For more info on MSBUILD, go to http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx


For database development try http://www.deltasql.org/wiki.

There is a central server (in PHP/mySQL, can be easily installed with the XAMPP package) were you store your SQL delta scripts. On each of your schema you need to add a table tbsynchronize which contains the latest script executed on that database. deltasql server then generates a synchronization script which contains the missing scripts for that schema.


Automate and script as much as you can, even the FTP part. Use ant/nant and batch files to do the repetitive stuff for you. If possible provide undo scripts for when things get bad. I update production code within 3 seconds in linux boxes (with a scripted process: backups, delta sql scripts, release code, restart servers) but on windows I'm not sure how neatly you could do that.


Ok, so I don't have a full answer, but why do you uninstall the services. You can just stop them and replace the files. I do this all the time. But I would like to see the answer you get as I have this same issue.


You could use deployment projects and web deployment projects in Visual Studio to create .MSI files to do the installations. You could even prompt for some of the information that might differ between the sites.

Also, take a look at the IIS Web Deployment tool. It's just recently gone RC1.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »