dotnetco.de

Easiest way of asp.net deployment

When it comes to deployment of asp.net projects there are several ways, as described for example on MSDN. Working with ASP.net for several years I’ve found the easiest way of deployment for myself is using zip / rar to pack an archive of updated files. This works very well in both company and personal webserver configuration:

  • In company I’m not allowed to deploy directly to the live server (as this is an admin job)
  • The admin needs to be able to easily deploy the changes to stage server and afterwards to live server.
  • The admin needs to be able to identify the changed files easily.
  • At home I upload the files to my IIS via FTP as that’s easier than connecting to the machine via RDP and starting an update installation.
  • Previously at home with shared hosting I only had access to my webspace via FTP and not via Remote Desktop of course.

Bearing these requests in mind I created a simple batchfile which does this job for me.

The batchfile is available for WinRar and 7-zip but could be modified easily for every packer which supports command-line packing.What it does:

  • It checks the current directory and all subdirectories for modified files.
  • It takes care of an exclusion list so e.g. your source code (*.vb, *.aspx.vb etc.) will not be added to the packed file.
  • It adds current date to the filename of the packed file, e.g. ‘MyFiles20091231.rar’
  • If the packed file already exists it will be deleted first.

Configure before first use:

  1. Set Archivename: Line 25 contains a variable ‘Archivename’. Set this to a name you like, e.g. ‘MyApp%yy%%mm%%dd%.rar’. You might remove the placefolders for current year (%yy%), month (%mm%) and day (%dd%) if you want to have always the same filename, but personally I prefer to have some kind of history, especially as these packed files are normally very small.
  2. Set Path to your packer: Line 31 starts with the filepath of the packer, e.g. ‘”C:\Program Files\WinRar\Winrar.exe”‘. Of course you need to change it if your packer is at another location.
  3. You might take a look at ‘Backup-ExcludeFiles.txt’. That’s an exclusion list, so all files listed here are NOT added to the packed file. You could use single filenames (‘web.config’), wildcards (‘*.zip’) or names of subdirectories (‘TestResults’).
  4. Now place all these files into your local application path, e.g. ‘C:\inetpub\wwwroot\MyApp’.

That’s all for the inital configuration!!

Configuration for every day use:
You’ve made some changes and want to deploy them? Just edit the 4th line of Backup.cmd. It contains a variable ‘LastUpdate’, holding the date and time of the last deployment. You have to edit this on your own. Why is it not computed automatically? Because maybe you made a deployment to stage and then add a bugfix. The new packed file of course also needs the files already deployed to stage, because otherwise you will get a problem while deploying to live. So this date should be the latest modification date for all your environments (local test, stage, live).
Now just start the batch file. You see a new file is created. This file could be forwarded to your admin, uploaded to another documentation system, or extracted locally to upload then via FTP to your (shared) hosting!

Download backup containing Backup.cmd and Backup-ExcludeFiles.txt

Leave a Comment