1. Windows Installer Overview
Windows Installer is the Microsoft technology for
deploying applications. This technology has been part of the Windows
operating system for many years and can be considered as an engine for
installing .Msi packages. An .Msi package, or installer package,
contains all files to be installed with your application
and other important information such as shortcuts, icons, license
agreements, other redistributable packages, and key/values to be written
to the Windows Registry.
Windows Installer is the most powerful technology for
deploying .NET applications with Visual Studio 2010. This is because
Windows Installer has few limitations, whereas it brings lots of
benefits. Windows Installer makes it difficult to provide updates, so if
you plan to release frequent updates for your applications, you should
consider ClickOnce. You should
choose Windows Installer as the deployment system for your application
if you meet one or more of the following requirements:
Adding values to the Windows Registry
Customizing installation folders
Installing assemblies to the Global Assembly Cache or installing and registering COM components
Installing Windows services and peripheral drivers
Executing custom actions and specifying launch conditions
Managing ODBC components
Creating custom shortcuts in the Windows user interface
Elevated permissions and deeper interaction with the user
In scenarios different from
the ones listed, you might instead consider ClickOnce. Visual Studio
2010 is the perfect environment for creating projects that can build
Windows Installer packages that install your applications on target
machines the most appropriate way. In next section you see how to
accomplish this.
2. Creating a Setup Project
First, create a
new WPF project with Visual Basic and name it DeploymentDemo.
This project just serves as the demo application to be deployed. When
the new project is ready, right-click the solution name in Solution
Explorer and then select Add, New Project. In the New Project dialog select the Other Project Types, Setup and Deployment, Visual Studio Installer templates subfolder and then choose the Setup Wizard project template, as shown in Figure 1. Name the new project SetupExample and then click OK.
The Setup Wizard is the most common project template
for generating setup procedures for Windows Installer because it
simplifies the process of packaging the output of other projects in the
current solution through a number of guided steps.
Note
The
Setup Project and the CAB Project templates enable, respectively,
creating an empty project for creating a Windows Installer package and
creating an empty project for packaging the application into CAB
archives. The Merge Module Project is used to create a merge module that
is basically an additional component for Windows Installer packages and
that contains redistributable packages generally storing libraries and
components. Finally the Web Setup Project is useful for deploying web
applications.
When you click OK, the Setup Wizard will be launched. The first dialog is just a welcome one so click Next.
The second dialog requires you to specify the project type. Leave
unchanged the default selection for a Windows application, as shown in Figure 2, and then click Next.
The third dialog is important because it enables
selecting the content of your package. Although you can perform this
later, this is the best place for adding contents. You must select the Primary Output option, as demonstrated in Figure 3, to include the application’s executable and its dependencies.
When you click Next you go ahead to the fourth dialog that enables specifying additional files to be packaged. Because this is not our case, click Next again. The fifth and last dialog contains a summary report for the new project, as shown in Figure 4.
If you missed something you can step back to the previous dialogs. Now click Finish so that Visual Studio generates the setup project for you. The new project is now available in Solution
Explorer and is almost ready to be built for deployment. To make the
deployment the most accurate possible, you can perform some
customizations, which are discussed in next section.