views:

153

answers:

2

I am planning a procedue to release our software to our customers using an advanced version of an existing procedure which uses windows batch scripts. I am hoping to improve this process and automate the installation of the following items:

  • Files. Files are simply copied to a destination.
  • MSSQL Databases. I guess I'll use the OSQL command to run these against a database.
  • IIS Virtual Directories. Server versions of windows generally have the IIS toolkit installed which has some tools for creating virtual directories and whatnot from the commandline so I will use that. I think the "iiscnfg" is the one I use to insert previously saved config files into IIS.
  • Windows Services. Our services have the ability to install themself from the commandline.

So for each application deployment I have a structure like this:

Releases\
| get-release.bat
| Release1\
| Release2\
| Release3\
| | Content\
| | | Application1\
| | | | bin\
| | | | | Application1.exe
| | | | etc\
| | | | | Application1.config
| | | | db\
| | | | | CreateDatabase.sql
| | | | | CreateTable1.sql
| | | | | CreateTable2.sql
| | | | iis\
| | | | | Application1Web.xml
| | | | pre.bat
| | | | post.bat
| | | | environment.bat
| | | Application2\
| | | Application3\
| | | Application4\
| | Release1.doc

So basically you open a terminal and CD to the Releases directory, run a command something like:

get-release "Release3"

which will run a series of commands on all the applications in the Release3 directory and copy all the files, configs, install all the databases and iis virtual directories.

There is a little bit more which it does like backup the destination directory for files, etc. but its irrelevant for the moment.

My question is whether anyone has any experience doing a deployment like this and if there is any mistakes I can learn from other peoples experience.

Unfortunately we cannot go with MSI packages or that NullSoft one (who's name escapes me for the moment). If its not done like this it is done manually so I'm really trying to help myself here.

+1  A: 

I don't see any problem with doing things like this with a batch file. However, you're going to have to give some thought to what some of the differences between machines (missing directories, already existing directories, already existing files, file versions, etc.) might be, address them, and test really well on a variety of machines.

It's too bad you can't use an installer, because installers already mitigate most of these issues for you. In essence, you will be rolling your own installer, and you will not benefit from lessons learned, best practices, etc., that an installer will give you.

Another thing you might not be able to do without an installer is install a file that is being locked by the operating system. Installers deal with this by copying the file to a temporary location, putting a "load on restart" entry into the registry, and then asking the user to restart the computer.

Robert Harvey
+1  A: 

I've rolled several scripts like this, and the ugliest parts to deal with are error handling -- how do you detect errors, what do you do when they occur, can you roll back all changes made to date, and so on. Relatively simple if you're doing a fresh install, not nearly so simple if you're updating an existing system. (You should never assume it will work perfectly every time--tomorrow's MS update might break today's script, after all.)

There are just a few things ;) you can't reasonably do from within a batch file. Can you slip in VB scripts, java scripts, some Powershell calls, or anything else to handle the difficult stuff?

Philip Kelley
I'm considering bundling the main functionality (creating IIS virtual directories, databases, etc) in .net 1.1 apps and glueing it all together with scripts. I don't know if they will help much though ... Perhaps we should write our own installer application (.net) but we are back to square one then.
Nippysaurus
Q1: Why can you not purchase/use an existing installer? Q2: How much will it cost to build your own? (No matter how simplistic, the system discussed in this thread is an installer.) Count hours spent developing AND testing AND debugging. How many hours? Times $ per hour per developer/tester? Factor in lost $ for lost time on inevitable new-system first-use issues. Q3: Given the expense of not doing so, why can you not purchase/use an existing installer? (All of my scripts were short and for a small target set, and so were cost-effective.)
Philip Kelley