January 21, 2021
Hot Topics:

Deploy Windows Applications with Visual Studio.NET, Part 1

  • By Thiru Thangarathinam
  • Send Email »
  • More Articles »

Trade Offs Between XCOPY and Windows Installer

As you can see, XCOPY is ideal for deployment scenarios that are simple and manually executed. However, many scenarios require a more robust deployment solution. In those cases, you should use the Windows Installer technology to install applications. The following advantages make Windows Installer ideal for creating setups and deployments for .NET applications:

  • If an application installed with Windows Installer gets corrupted, it can perform a self-repair using the repair feature of Windows Installer packages. In XCOPY-based deployments, you need to manually replace the corrupted component with the newer version.
  • The automatic rollback feature not only ensures that the installed components are uninstalled but also brings the machine back to the stage it was prior to the installer starting, if the installation fails.
  • Because Windows Installer uses an MSI installation database for storing all the information, you can get the information about which files are copied, which Registry keys are created, and so on.
  • If you're developing an application that you want to distribute to multiple users (or sell as a package), you can automate the entire installation process using Windows Installer's sophisticated installer technology—thereby simplifying the deployment.

Visual Studio .NET Deployment Project Templates

Visual Studio .NET comes bundled with five types of project templates that you can use to set up and deploy .NET applications. You can access these project templates the same way you would any other project in Visual Studio .NET, by using the File | New Project dialog box.

Figure 1: Setup and Deployment Project Types Available in Visual Studio .NET

Figure 1 shows the different setup and deployment project types available in Visual Studio .NET. Take a brief look at each of the available project types:

  • Setup Project template—Use the Setup Project template to create a standard Windows Installer setup for a Visual Studio .NET application.
  • Web Setup Project template—Use the Web Setup Project template to create a Windows Installer setup program that can be used to install a Web application onto a virtual directory of a Web server.
  • Merge Module Project template—Merge modules enable a set of files to be packaged up into an easy-to-use file that can be re-used and shared between setup programs that are based on Windows Installer technology. The idea is to package all the files and any other resources that are dependent on each other into the merge module. As you can imagine, this type of project can be very useful for packaging a component and all its dependencies into a single unit, which then can be merged into the setup program of each application that uses the component. During the installation, the merge module component is installed only if the component is not present on the machine. The merge module Windows installer package files are identified by the file extension .msm. For example, the latest versions of MSXML (Microsoft XML) Parser are also available in the form merge modules. If your application uses MSXML Parser, you can easily package the merge module into the setup program of your application.
  • Setup Wizard template—Use the Setup Wizard to guide you through the process of creating one of the above setup and deployment project templates.
  • Cab Project template—You use the Cab Project template to create a cabinet file (.cab). A cabinet file can contain any number of files, but no installation logic. It is generally used to package components into a single file, which can then be deployed on a Web server to enable the browser-based clients to download these components onto their local machines before installing them. For example, controls hosted on a Web page are often packaged up into a cabinet file and placed on the Web server. When the browser encounters the control, it verifies that the control isn't already installed in the local computer, at which point it downloads the cabinet file, extracts the control from it, and installs it onto the user's computer.

Creating an Installer Package

Now that you know the different setup project types, you can learn the steps involved in creating a setup and deployment project for a Windows application. During this example, you will create a simple Windows application and see how to deploy it. The application, named FormattingApplication, simply allows you to format the contents entered in a rich textbox. Because the main focus of this article is on creating Windows Installer packages, you will not spend too much time on this. However, you should download the source code for this project along with the support material on the final page of this article.

Start by adding a Windows Installer project to the solution that contains the C# formatting application project. Now, add a setup project to your existing solution by selecting File-> Add Project-> New Project from the New Project dialog box. Name the project FormattingApplicationSetup.

Page 3 of 5

This article was originally published on May 14, 2004

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date