Deploy Your Applications and Components Using the Windows Installer


Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame


Whenever you hear about deployment of your application or component, you get scared of the traditional scripted setup programs. The main goal of this article is to help .NET programmers get used to this easy-to-setup program that allows you to deploy your application even if you don't know how to write the setup script. Microsoft Dot NET Setup Deployment will make the setup for you with a few simple clicks. It is also provided with self-taught, easy driven wizards. Many programmers who are using Microsoft Visual Studio Dot NET are not fully aware of this Windows installer that comes with Visual Studio; they are going for other setup programs that need hard scripting knowledge. Using Windows Installer is very easy.

About Microsoft Windows Installer

Windows Installer enables you to deploy your applications and components in an efficient manner. The installer provides new capabilities to advertise features without installing them, to install products on demand, and to add user customizations. Windows Installer is an installation and configuration service that reduces the total cost of ownership. The installer enables customers to better address corporate deployment and provide a standard format for component management.

Run-Time Requirements

This technology is available as a redistributable for Windows Installer version 2.0, from the SDK Update site.

Features of Windows Installer

  • It is based on a data-driven model that provides all installation data and instructions in a single package, in contrast to traditional scripted setup programs.
  • It also supports self-repair—the ability for an application to automatically reinstall.
  • It provides the ability to roll back an installation.

The deployment tools in Visual Studio .NET build on the foundation of Windows Installer, providing you with rich capabilities for rapidly deploying and maintaining applications built with Visual Studio .NET.

Creating your first deployment project

Visual Studio provides templates for four types of deployment projects:

  • Setup Project: Builds an installer for a Windows-based application.
  • Merge Module Project (.msm): Packs components that might be shared by multiple applications.
  • Web Setup Project: Builds an installer for a web application.
  • Cab Project (.cab): Creates a cabinet file for downloading to a legacy Web Browser.

In addition, a Setup Wizard is provided to help step you through the process of creating deployment projects.

  • For a Setup project, the installer will install files into a Program Files directory on a target computer.
  • For a Web Setup project, the installer will install files into a Virtual Root directory on a web server.
Note: If you have created a standard deployment project and later decide to deploy it to a web, you will need to create a new project.

Five Easy Steps

Step 1

Open the Visual Studio IDE and select File->New->Setup and Deployment Projects. Select the Setup Wizard. Give the file name and location where to store that project, as shown in the following figure.

Step 2

The Welcome to Setup Project Wizard dialog box will appear. It is a simple four-step wizard. Click the Next Button. The second step will ask the type of the setup. Choose the appropriate reply; here I have chosen setup for Windows application. Click Next.

Step 3

The third step of this wizard will ask you to add your developed application or component and other files that you need to place in the clients machine; for example, say, documentation files.

Now, it will display what you see in the following figure.

Step 4

As you can see in the preceding figure, the application folder is the folder where your application and supported files will be installed. User's Desktop and Programs Menu are the client's desktop and programs menus, respectively. If you place the short files of your main application and Help files on the user's desktop and programs menu, during the installation the application supported files and the shortcuts will be placed automatically as you directed by placing the intended files in Application, User Desktop directories, and programs menu.

You can use the following editors during the deployment of your application.

You can find these editiors in the solution explorer, each as a button as shown below.

File system editor

Allows you to add project outputs, files, and other items to a deployment project and specify where they will be installed on the target computer.

Registry settings management editor

Allows you to specify Registry keys and values to be added to the Registry of the target computer.

File types management editor

Establishes file associations on the target computer.

Custom actions management editor

Allows you to specify additional actions to be performed on the target computer at the end of an installation.

Launch condition management editor

Allows you to specify conditions that must be met to successfully run an installation.

User interface management editor

As shown in the figure above, the User InterfaceManagement Editor is used to specify and set properties for predefined dialog boxes that are displayed duging the installation on the target system.

You can add the dialog boxes, such as end user license agreement dialog and serial key dialog, as shown.

The Customer Information Dialog is important to protect your software. For that first set the Show SerialNumber property to true (it is false by default). There will be a template for the serial key called SerialNumberTemplate:-Valid editable characters for the SerialNumberTemplate property are:

Character Meaning
# Requires a digit that will not be included in the validation algorithm.
% Requires a digit that will be included in the validation algorithm.
? Requires an alphanumeric character that will not be included in the validation algorithm.
^ Requires an uppercase or lowercase character. Numeric digits are not valid here.
< Any characters to the left of this character will not be visible in the dialog box.
> Any characters to the right of this character will not be visible in the dialog box. Required as a terminator if the < character is used.

Note that any other character is treated as a literal constant. The Default template is <###-%%%%%%%>, which creates two text boxes separated by a dash surrounded by spaces. The first has #, which means that the user must enter three numbers but those numbers will not participate in the validation algorithm. The second box had seven digits; % means that it will be involved in the validation. You apply modulo 7 to the sum of these required digits; if it equates to 0, the algorithm returns true and the user can proceed to next dialog box. Example: <###-%%%%%%%>, 124 - 7134501 is one of the keys by which the user can proceed to next dialog box.

The first three digits—1, 2, and 4—can be any digits because they will not participate in validation. The next seven digits, 7134501, sum to 21; if you apply 21%7, you will get 0, so this is okay. Likewise, you have to proceed. You can add the dialog boxes, such as the end user license agreement dialog and serial key dialog as shown.

Step 5

When you build the application, you will find the install program for your software or component in the projects debug directory.


I hope that many of the .NET developers who use traditional setup script programs will find this an easy and simple way to deploy your software. More than that, if you got the licensed Visual Studio .NET with you, there is no need to purchase setup applications from other companies because Visual Studio .NET itself offers it to you. I think that I had given enough features of Windows Installer that comes with Visual Studio .NET. Now it's up to you.

About the Author

Prabhakar Manikonda

Prabhakar Manikonda MS CS, MA Social Work, MCSD.NET [ Microsoft Certified Solution Developer ] Proven track record with seeing successful projects through to completion. Excellent team player and completer-finisher. Specialist in methodology, architecture,object-oriented design, and project management. Plan and manage workload, monitoring and resolving programming issues Transform requirements into architectural, Publishes white papres and articles in software development and runs software consulting & recruiting personal web site: http://www.mprabhakar.com


  • Registry License

    Posted by chethana on 06/28/2013 07:41am

    I'm getting exception saying "Error executing application: Your license is invalid".. what is the solution for this? kindly help me at the earliest

  • Helpful article

    Posted by Andreas Mutota on 09/28/2012 02:56pm

    The article “Deploy Your Applications and Components Using the Windows Installer” was very helpful I must say. It made understand how algorithm works. But there are two I need clarity on. A. I worked the algorithm but during installation when I enter serial number in number format goes through even if it is not correct. How do sorting it out? B. Which algorithm character used to represent Letter?

  • Add-in update

    Posted by Chris on 06/13/2012 07:53am

    An alternative to the setup project type in Visual Studio is the Advanced Installer extension: http://www.advancedinstaller.com/user-guide/tutorial-ai-ext-vs.html It's free, it integrates with Visual Studio and it's a lot easier to use.

  • Figured the Icon issue, but another question

    Posted by malinwah on 11/19/2006 11:44pm

    For anyone else struggling, once inside the file system (where it shows the three folders:Application, User's Desktop, and User's Program, left click the User's Desktop and set the "AlwaysCreate" property to true. Then go back to the User's Desktop icon and right click to add>Assembly. Once the "Component Selector" popup appears, locate the .exe in the Debug folder in the original application. Then build. The installer will be found in the Debug folder of the installer application. Took me a while to figure this, but it works. Now for the second question, I've added the dll that I created for my project in step 3, and the dll is visible in the solution explorer. But the issue is when I use the newly created installer to deploy my application, the project is displaying that the created dll cannot be located. How do I get the installed program to detect my dll through the wizard? Thank You

  • Having the hardest time

    Posted by malinwah on 11/19/2006 05:16pm

    In step three, I've added my dll and my exe (guessing the one in the debug folder of my application). I see the assemblies, but now I'm trying to create a working desktop icon with the wizard. So far, I've right clicked on the User's Desktop that I saw of the three, Application Folder, User's Desktop, and the User's Program Menu. When the icon appears, it opens the contents of my desktop. Not what I wanted. How do I create (or assign) a proper desktop icon for my application through the wizard. Thanks so much, Tatjana

  • about serial key

    Posted by email2babu on 02/17/2006 12:58pm

    can you please tell me about serial key's and how to set the serial keys for our installer.

    • RE: How to go about this!

      Posted by mprabhakars on 03/09/2006 09:18am

      That is a good question, you have asked about the custom action feature that is provided in .NET To create the custom action Create Ur Radio buttons Form write the logic to copy the selected extension files Built the solution. Then in the debug directory of your solution you will find the .exe file for your application. Just set that in the custom action installer. Using below steps ok. To add the custom action File -> new Project -> Setup & Deployment Wizard. Next. Next Next Finish.. then when the IDE opens up. 1. Select the Custom Action Installer project in Solution Explorer. On the View menu, point to Editor, and choose Custom Actions. The Custom Actions Editor is displayed. 2. In the Custom Actions Editor, select the Install node. On the Action menu, choose Add Custom Action. 3. In the Select Item in Project dialog box, double-click the Application Folder. 4. Select the Primary output from OpenWeb item. 5. Click OK to close the dialog box. 6. In the Properties window, select the InstallerClass property and set it to false. 7. On the Build menu, choose Build Custom Action Installer.

    • How to go about this!

      Posted by ArvindKishore on 02/22/2006 09:04am

      Thanks man for such an informative article. I have one request. I am creating installer using net setup and deployment, but i want to give the option to the user to install what they want. For example, my installer will consist of html, pdf. dll, exe etc. I want to give the installable to give the person who is installing to install all the files or only pdf or html ....files. I hope i am able to express myself. Can i use the checkbox provided by the windows interface interface, if yes then how can we do it. If no, then is there any other way to do it. Your input will be awaited. Thanks

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Most Popular Programming Stories

More for Developers

RSS Feeds

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