Writing Robust Installers

 < Day Day Up > 

When you’re ready to start delivering your application to customers, you probably feel as if you’re at the end of a long journey. The journey’s not quite over yet, though. In some cases, you may be able to get away with just handing out the compiled executable to customers with some instructions. For example, if your product is a simple library of functions designed to be called from other applications, you probably don’t need to do much more than zip it together with the help file and hand it out. As soon as the installation becomes more complex (say, because the help files need to be integrated with the default .NET Framework help), you’ll find that an installer is helpful. As a rough rule of thumb, whenever setup becomes so complex that it requires step-by-step instructions, you should automate the process.

In most cases, you’ll need a formal setup program (an installer) for your application. A typical installer these days performs dozens of tasks, from copying software to the hard drive, to setting up websites, to providing product registration, to building desktop icons, and more. Creating this extra piece of software is often not a trivial job, but it’s worth the effort.

Surveying Installation Creators

When you’re ready to build your installation, the first choice you need to make is how to create it. You can find a variety of programs out there designed to help you create software installations for Windows. Choosing between them is, as with other categories of software, a matter of features and budget, but I recommend you choose one of these existing installation creators.


Don’t roll your own setup.

Setup applications are pretty complex beasts. They need to run perfectly on many different versions of Windows, whether or not the user has administrative privileges. They must integrate with the Add/Remove Programs Control Panel applet. They need to support a user interface that’s already familiar to users. With all these requirements (and more), you’re much better off buying an existing product, or using one of the free alternatives.

Table 15.1 lists some of the major installation creators that I’ve seen used for .NET applications. Let’s review them briefly.

Table 15.1: Some Representative Installation Creator Software



Inno Setup




InstallShield DevStudio


InstallShield Express




Visual Studio .NET


Wise for Visual Studio .NET


Wise for Windows Installer


  • Inno Setup Inno Setup is a free tool (and it’s free whether you’re using it to install free applications or commercial ones). It performs the basic setup tasks: installing files, creating shortcuts, modifying INI files, and making Registry entries. It also handles the corresponding uninstall tasks. Inno Setup can be extended by writing code in a Pascal-like scripting language. It uses its own setup engine rather than the Windows Installer service. Inno Setup depends on plain-text scripts (which resemble INI files) to control its actions, but there’s an optional user interface called ISTool available that provides a nicer way to edit these scripts. You can’t customize the user interface of installers created with Inno Setup, other than by omitting certain steps to the wizard (for example, you can decide whether to collect user information).

  • InstallAnywhere.NET InstallAnywhere.NET was originally named ActiveInstall, before its purchase by Zero G Software. As of this writing, it’s unavailable pending the first release under the new branding, but I had the opportunity to test-drive ActiveInstall and presumably the new version will have the same general capabilities. ActiveInstall provides a full IDE for creating and editing Windows Installer—based setup programs, modeled on the Visual Studio .NET (VS .NET) IDE. The IDE contains sections for tasks such as modifying the Registry or working with Internet Information Services (IIS). The IDE is scriptable with Visual Basic for Applications (VBA) and includes source code control integration. ActiveInstall handles quite a number of high-end tasks, including SQL scripting, COM+ application deployment, and IIS virtual directory creation. It features a .NET project wizard, as well as a log analyzer and a runtime debugger, and is a promising entrant in the high end of the market. (ActiveInstall 2.0 had a $899.95 price tag).

  • InstallShield DevStudio and InstallShield Express InstallShield DevStudio, at $1199, is one of the top competitors in this market. It can create scriptable setups that use either the Windows Installer service or InstallShield’s own engine, and runs in either stand-alone mode or integrated into VS .NET. In addition to regular installers, it can build merge modules and patches, installers for web projects and Smart Device projects, and more. It can create a setup directly from your VB .NET or C# project. The Project Assistant provides you with step-by-step help on every aspect of building an installer, and you can also edit everything at the most detailed level possible. DevStudio can customize every aspect of the installation, and it handles high-end tasks like COM+ setup or Microsoft Data Access Components (MDAC) installation. Some projects might find the complexity of DevStudio to be overkill, but the InstallShield people have tried to cover every setup contingency in this product. The $349 InstallShield Express is a stripped-down version of the same product, missing some features (such as dialog editing and merge module creation), but it will work for many setups.

  • NSIS NSIS is the Nullsoft Scriptable Install System, a free and open-source alternative from the creators of the popular WinAmp music player. Like Inno Setup, it relies on your writing a special plain-text scripting file to drive the installer (and there are a couple of free editors available to make this easier). NSIS has very low overhead and is designed to compress the files you’re installing as well, to achieve the minimum possible download size. You can write custom dialog boxes and web setups, as well as patch installers, with NSIS. The whole system is extensible through a plug-in interface, and NSIS includes many contributed plug-ins. This means that NSIS can do just about anything that you can write C++ code to implement. NSIS uses its own setup engine.

  • Visual Studio .NET If you own VS .NET, you can build Windows Installer-based setup programs directly in the IDE. You do this by inserting a new Setup and Deployment project into your solution. VS .NET has a wizard to build a basic setup, or you can start with an empty project and customize it from scratch. The various editors built into setup projects let you specify the files, file types, Registry keys, user interface, and launch conditions associated with your setup program. You can also build custom actions, which are pieces of .NET code that will be executed during the setup project. However, there are a couple of drawbacks to the built-in setup projects. First, there’s no direct editor to get into the Windows Installer tables, so some of the power (and complexity) of the Windows Installer service is hidden from these projects. Second, you must arrange to deliver the .NET Framework before these setups will work at all.

  • Wise for Visual Studio .NET and Wise for Windows Installer Wise Solutions is another major vendor of software that creates setup programs. Wise’s .NET-aware products include Wise for Windows Installer (starting at $549) and Wise for Visual Studio .NET (starting at $1199). As you can probably guess from the name, the latter version integrates directly with VS .NET. Wise offers an Installation Expert user interface that lets you fill in dialog boxes to dictate your setup’s options, as well as other editors that will let you see the exact script and table entries that the Expert generates. Wise can start from existing VB .NET or C# projects, and handles high-end tasks like configuring IIS virtual directories and .NET Framework security, installing COM+ components, and executing SQL Server scripts. Wise also supports mobile devices as well as core Windows Installer features (like merge modules and setup validation).

In addition to these products, there are two other useful resources you should know about when you turn your attention to building a setup. First, the Microsoft Windows Installer SDK contains all of the information you need to understand what’s going on inside the Windows Installer, though it’s not always easy to read. The SDK also contains some essential tools and a bare-bones setup editor. You can download it from www.microsoft.com/msdownload/platformsdk/sdkupdate/. Second, InstallSite (www.installsite.org/) offers a wide variety of resources related to the Windows Installer, including links to products, reviews, troubleshooting information, and more.

To give you some hint as to what the high-end setup solutions look like, Figure 15.1 shows an InstallShield DevStudio project open within VS .NET. I won’t actually be using this setup, because I don’t need the high-end capabilities that DevStudio provides for this simple application.

click to expand
Figure 15.1: InstallShield DevStudio in Action

Choosing an Installation Creator

Given all these choices, how do you decide which installation creator to use? Here are some factors to consider:

  • Cost With a few tools, the spread in cost is as wide as it is in setup programs, from free applications to high-end versions of professional tools that can run over a thousand dollars. While the more expensive products are also more capable, many applications can get by with the less expensive alternatives.

  • Functionality With a high-end package, you’ll find some advanced operations to be as easy as basic ones. For instance, creating a virtual directory for an IIS server (important when you’re deploying an ASP.NET application) can be a matter of filling out a dialog box. You can still perform these actions with basic packages, but you’ll invest more of your time in writing and testing custom scripts to do so.

  • Customization The level of customization you can apply to the setup process varies from package to package. In some cases, you might only be able to put your application’s name into otherwise standard dialog boxes. In others, you can redesign and extend the user interface that users see when they’re setting up your application.

  • Windows Installer support The Windows Installer service is Microsoft’s built-in set of APIs for setup programs. It’s present in all modern versions of Windows. The Windows Installer service provides such things as setup logging, uninstall cleanup, and install-on-demand (where a feature isn’t actually installed until the first time that a user attempts to use it). Some setup programs use the Windows Installer service, while others implement their own custom setup engine instead. The custom engines are often simpler and smaller than the Windows Installer service. But the Windows Installer service provides a consistent user experience, and its use is a requirement to obtain the “designed for Windows” logo from Microsoft, which may be important to your marketing efforts.

  • Delivery mechanisms Any installation creator can build a setup program that’s designed to run from a CD-ROM or a downloaded file. But some have additional flexibility. For example, you may be able to build a setup that runs from a website and that only downloads necessary files, or a patch or update to an existing application to bring it to a new version. If these delivery mechanisms are important to you, you’ll want to make sure that they’re supported by your program of choice.

  • Integration Some of the installation creators integrate with VS .NET, or can read VS .NET solution files, or both. Others are strictly stand-alone affairs. You’ll find it easier to build a setup for a .NET application using an integrated product.

Given all these factors, I think that many .NET developers will find that the VS.NET setup and deployment projects hit the sweet spot. When and if you outgrow this solution, you can look at some of the more full-featured commercial applications.

General Installation Tips

When you’re creating the setup program for your application, there are some factors that you should keep in mind. Here are some suggestions on building good setup programs:

  • Build your setup with your application. As with your help files and documentation, you should be building your setup program concurrently with your application. That’s because, like everything else, the setup program will need to be tested. Although your development team and internal testers could probably do their work without the formal setup program, that doesn’t do anything to ensure that the setup program will work for end users. As soon as you’ve got any files to install, you should be crafting the means to install them.

  • Install everything. The setup program should offer to do as much work as possible when installing your application so that users can carry out a single process and have a working program. If your application requires a database, you should set up the database. If it runs in conjunction with a website, build the IIS virtual directory. If it installs a service, you should register the service so that it runs when the operating system is restarted. There are few things more annoying than clicking Finish, waiting for the setup program to finish, and then discovering a readme file with a dozen more steps.

  • Leave the user in control. Some changes are so sweeping, though, that you shouldn’t make them without user consent. Take setting up a SQL Server database, for example. While you could just search for a database server and use the first one that you find, that wouldn’t be very friendly. It’s far better to prompt users for a server name and login information, and to then use the server that they selected. Your setup program should be capable of doing everything, but for things like creating websites or installing databases, make sure users know what they’re getting into. If your application is very complex, you may even want to offer to install only parts of the application. You’ve probably seen the dialog box shown in Figure 15.2, which is the one that Microsoft Office 2003 uses for this purpose. Most installation creators offer some support for a similar dialog box.

    click to expand
    Figure 15.2: Choosing the pieces of Office 2003 to install

  • Don’t do the unexpected. Some setup authors seem to think they can do whatever they want to a user’s computer. It’s certainly possible to write a setup that deletes or disables a competitor’s product, hijacks a file extension, or insists on creating a desktop icon. In general, you shouldn’t make changes to the system that will surprise the end user. Things can get even worse if your setup disables features that the user depends on. For instance, imposing your own system color scheme can make it impossible for a sight-impaired user to even read the screen.

  • Clean up on uninstall. If the user should decide to remove your application, your setup program (or, if it’s a separate application, your uninstaller) should do the best that it can to clean up and reverse any changes that the setup made to the system in the first place. This includes removing files and Registry keys, deleting Start menu entries, and so on. There’s one exception to this general rule: You may not want to delete databases and data files that were created or altered by the user without asking first. That way, if users decide that removing your application was a mistake, their previous work will still be waiting when they reinstall the application.

  • Test your setups. Like your application, your setup program should be tested in the environments where you expect it to work. Try installing your application to make sure that it works properly, and then try removing it to make sure that the setup program cleans up properly. You’ll need to carry out these same tests on a variety of operating systems to make sure that everything works. As with other testing problems, virtual machines can be very helpful here.


In general, your setup program shouldn’t do anything that you wouldn’t like some other application’s setup program to do to your computer.

 < Day Day Up > 

Coder to Developer. Tools and Strategies for Delivering Your Software
Coder to Developer: Tools and Strategies for Delivering Your Software
ISBN: 078214327X
EAN: 2147483647
Year: 2003
Pages: 118

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net