6.2 Setup Project Types

A Setup project should be in the same Visual Studio .NET solution as the project whose output it will be installing. New Setup projects are added to a solution in the same way as any other project. (Either use File Add Project New Project... or use the solution item's context menu in the Solution Explorer, choosing Add New Project....) There are several different project types in the Add New Project dialog's Setup and Deployment Projects category, as Figure 6-2 shows.

Figure 6-2. Setup project types
figs/mvs_0602.gif

When you add a new Setup project, the project will not be added to any of your configurations by default. This is because Setup projects take a while to buildsince the output of a Setup project is usually needed only toward the end of the development cycle, it would be a waste of time to wait for an .msi file to be built every time.

You can get Visual Studio .NET to build your project either by adding it to one of your configurations or by selecting Build from the project's context menu in the Solution Explorer.

All Setup projects work in much the same way. The main differences are related to the way in which the component will actually be deployed. The role of each project type is shown in Table 6-1.

Table 6-1. Setup project roles

Project type

When to use

Setup Project

For applications that will be installed on the end user's computer.

Web Setup Project

For applications that will be installed on or deployed through a web server.

Merge Module Project

For components that will be used by other applications. (Merge modules can be imported into either normal applications or web applications.)

Cab Project

For legacy component installation through a web browser. (Typically used for ActiveX controls.)

Setup Wizard

To create one of the four other project types, according to the selection made in the wizard.

Although it is usually fairly obvious which kind of Setup project you require, there is one exception. If you were writing a .NET Windows Forms application, you would expect to create a normal Setup project, since the application runs on the end user's computer. And usually you would be right. However, .NET allows such applications to be deployed via a web server. In this case, although the code ultimately ends up running on end users' machines, the installation step is done on the web server. So if you plan to deploy your Windows Forms applications via a web server, you need a Web Setup project.

Cab projects are provided only for support of legacy scenarios. Cab files do not use Windows Installer, so there is a great deal less flexibility about how the target machine will be configured. You should use one of the other project types unless backward compatibility requirements force you to use a Cab file. Cab projects are discussed in more detail toward the end of the chapter.