How to create an Installer for Windows Applications

Many of us have been programming windows applications for some time but have not had the chance to install our finished applications on other computers. It used to be as simple as creating a .exe file and the file will execute on any computer running the same operating system. Within the .net platform, things are a little more complex. First, the executable code that we create is a neutral code, which is not machine language. In fact, the advantage is that it is machine-independant. So theoretically any machine (Mac, Intel,...) that has Microsoft Framework installed on it will be able to execute the code. That is why an application developed on Windows XP will run on W98, as long as Microsoft Framework is installed on the W98 machine.

Secondly the executable code does not contain all the elements required to run the application, namely we need libraries, .dll, data etc. The whole complex task of determining what is required, and putting it in a box (called packaging) is taken care of by the Setup Project, which we can add to our solution.

The setup project will determine the required elements to be installed on the foreign machine, and will be all packaged into a file with a .msi extension (suffix).

The whole process is relatively easy and will be described in the following paragraphs. Here we assume that you have created an application that is ready to be packaged. However, to be absolutely certain, we suggest that you create a simple test projet, and try to experiment with it before you actually package your real project.

1. Add a setup project within your application solution.

Open the application. From the menu, select FILE, ADD PROJECT, NEW PROJECT, and the following screen will be displayed if you are using Visual Basic.Net version 2002.


In the Project Type (left) pane, select Setup and Deployment Projects, and in the Templates (right) pane, select Setup Wizard. The name will default to Setup1. You can change it to read something like YourApplicationSetup. Click OK to close the New Project screen and the following Setup Wizard screen will appear.

2. The Setup Wizard




Click Next to continue to the next screen.


For a Windows application, select the first option (Create a setup for a Windows application), then click Next.



This dialog screen allows the user to choose various files and items to be included in the application installer. The minimum will be the option Primary Output from YourApplication. Select any other option that you may require. Click Next.



Select all other files that are required to run your application, such as documentation, readme file, images, etc. Click Next.


The screen summarizes the actions that are about to be executed. Click Back to modify your selections, or Finish to complete the Setup project. A screen similar to the following will be displayed. Notice that a new project (setup1 in this screen).


3. Configuring the Setup project

Many configuration options are available to customize your setup project. The minimum recommended are:
Author
Description
Manufacturer. By default, the subfolder of Program Files will be named according to this value.
Product Name. By default, the application subfolder (under Manufacturer) will be named according to this value. Others that may be configured are:
AddRemoveProgramsIcon. You could choose an icon to be displayed in the Add/Remove Programs dialog box of the Control Panel.
DetectNewerInstalledVersion. When set to true (default), the installer will not overwrite a higherversion of the same application during installation.
RemovePreviousVersions (default false). If set to true, the installer will remove previous versions before installation.
Title. For the installer package, defaults to the application name.

Finally, the installation parameters on the user's file system may be configured according to needs. The parameters are located in each of the items of the File System (left) pane.

When all configurations have been completed, you will be ready to build the setup project.

4. Building the project


Debug or Released The installer will be placed in the Debug or Released folder, according to the status of the application. To change the status, right-click the setup project in the Solution Explorer Window and select Properties from the context menu. In the properties page, select the target configuration. You could make other changes as required.

Build Right-click the setup project again, and select Build from the context menu. It will take a little while to compile and build the projects and generate the .msi file. The MSI installer package will be stored in the Debug or Release folder, according the status you chose earlier.

5. Installation on the Target Machine

The target machine can be running Windows XP or Windows 98. It must have previously been installed Microsoft .net Framework 1.1. You could verify this using Control Panel/Add Remove Programs. If the Framework is not yet installed, you could install it at the WindowsUpdate site.
To install the application, the complete folder (Debug or Release) could be transferred to the target machine. Double-click the setup.exe program and follow the installation instructions. Once it is installed, the application will be available on the target machine.

updated: 2004-05-02