I love installers. I’ve found that wherever I work I end up writing one for the software and I wouldn’t have it any other way. There’s something that gives me that warm, fuzzy feeling inside when just a few buttons clicks can make the process of putting software on a machine seem trivial and just as easily remove it when in fact there’s a whole load of clever stuff going on underneath. Still waters run deep.
Take my last company. Before I wrote an installer it would take a person around a day to properly deploy the software. It consisted of C++ COM dlls, C++ COM+ components, an ASP.NET web site and a SQL Server backend. For anyone who’s had to deploy this type of software you’ll know that there are a great number of things that can go wrong and add time to an install. Never mind the fact that different operating systems (such as the different editions of Windows 2000 and 2003) all have their own little nuances…
I’ve seen in a lot of places a “deployment document” written consisting of a list of steps to perform when installing and you have to keep it up to date when you encounter problems as you go along. You end up with a numbered list where each item consists of a bullet pointed list and this is why an install takes a day. I find it surprising that companies seem to consider writing an installer as one of those “we’ll do it if we ever get time” projects that they never get around to. It’s surprising because the gains you get for such a small amount of work are immense.
At my last place I probably took a few weeks to write the installer and it dropped the time to install our software from a full day to around 10 minutes – and it always worked (once the bugs were ironed out!). Finally, instead of a customer install being a case of “okay, what’s going to go wrong this time?” it was a simple task that took no time at all. It was stress-free and made us look like a real bunch of pros to the customers.
If a glitch came up on a certain operating system, I didn’t go and append another “if this happens do this…” bullet point to some 50 page Word document, I fixed the installer and promptly forgot about it – the installer would deal with it.
I’ve used most of the tools out there including Windows Installer, InstallShield, Wise and the free and rather good Inno Setup which I’ve used more and more recently. I came to realise that you spend most of your time with installers writing code to do custom, tricky things like set up a COM+ application or configure a web site and despite products like Installshield supporting this, they aren’t flexible enough and I’d end up rolling my own code in VBScript or in a C++ dll I’d call. Inno Setup has been just fine for this.
However I’d been aware of another free tool out there called NSIS but had never actually sat down and learned how to use it. Until last week. And I must say, it’s amazing. I can see why companies like Google are using it – you can write a highly sophisticated installer in no time at all.
Installers consist of a bunch of tasks you need to do in sequence and you undo them in an uninstaller. You may want to create a bunch of shortcuts, copy some files, register some libraries, create a web site and configure some configuration files. Inno Setup was fine for things like that but if I needed to find some existing shortcuts and delete them, then add some new ones, then check to see if something was installed and if not download it from the internet and install it, then copy some files and so on it wouldn’t support it and I’d have to jump through hoops to do it. The steps weren’t fine-grained enough. NSIS lets me do whatever I want in any order I want, both installing and uninstalling.
I’ve been writing the new installer for version 2 of my background switcher and I needed it to do things like check if MS.NET is installed and if not, download and install it. I wanted it to fix up an install of any previous versions of my app installed including removing shortcuts that were in the “All Users” start menu when they shouldn’t be (naughty Inno Setup). I also wanted more fine-grained control over the uninstall process which I couldn’t really do before but with NSIS it’s easy. I can control the order things happen (e.g. delete this shortcut, then copy these files, then launch this application, then copy another file) to a degree I couldn’t do before and it’s completely extensible – I can create custom pages and call the windows API or write my own custom dlls.
And I’ll tell you something else, you could spend £1000 on a commercial product like Installshield or Wise, or £0 on NSIS and believe it or not, there’s nothing Installshield or Wise can do that you can’t achieve with NSIS – and trust me you spend more time working around the weaknesses in the big products than you do writing code for an NSIS installer. Now, guess what product I’ll be using to write the installer at my new job? I’ll give you a clue – it’s a four-letter word. And it doesn’t start with “W”…