Click here to Skip to main content
13,295,178 members (70,865 online)
Click here to Skip to main content
Add your own
alternative version


67 bookmarked
Posted 10 Jan 2004

All about Installers - Customizing Windows and Web setup projects

, 10 Jan 2004
Rate this:
Please Sign up or sign in to vote.
This article guides how to customize an installer for specific needs of the application.


The deployment is an essential part of the application life cycle. All that user wants from self-defined and self-controlled application is that it should be easy to deploy the application and undeploy without any hassles. This article mainly targets at how to customize the installers to satisfy the application needs. More often than not, Installers need customization to do pre/post processing during installation.

Visual Studio provides different ways to create installers. You can create installers for windows and web applications by creating set up or web set up projects. This article assumes that you need to customize an installer using VS set up projects. You will learn how to write an installer, and customize with different windows based on the need, pass parameters to the custom windows, commit/rollback based on the checks.

Installer Class

Creating an installer for the a windows or web project is a fairly simple job. All that you need to do is, open up your project for which you want to create installer, add a Setup and Deployment Project from File -> Add Project -> New Project. You can select the respective template from Templates window. The following code snippets describe based on a web setup project. The setup project contains few editors to based on their requirement. File System Editor is the default editor displayed, it provides interface to add files to the set up. There are two ways to add files to the set up project. Right clicking on Web Application Folder , it gives an option to add project output or file. Choosing Project Output, You get list of all projects in the solution. Select the project in concern, and add Primary output and Content Files. The second way to add files to the web setup project is selecting each file from the Web project and including them in same directory structure as of the web project.

If you want edit Registry during the installation, Registry Editor can be used to add registry keys under the respective node. User Interface Editor lists the different stages of installation and the dialog windows displayed during each stage. Figure 1 displays the User Interface Editor.

Figure 1 : User Interface Editor

The interesting part is adding custom dialog windows during the installation at particular stage. Right clicking on the Start/Progress/End node and select Add Dialog option. It shows list of predefined windows witch contain Radio Buttons/CheckBoxes/TextBoxes. Though there is not much control over these controls, but these windows allow to disable any particular control (EditVisible property) or provide a default value (EditValue property). The most important property is EditNProperty, using which the value of the control can be accessed when required (like [EditNProperty]). You can change the order of the windows appearing during the installation using move up/down options.

All these windows are predefined and most of the times, they do not fully provide the kind of functionality that most of the applications need. For example, If the installation has to take username/password as input, the default windows cannot be changed to accept password characters. There is an alternative to customize the installation for these kinds of requirements. This can be achieved using Custom Actions Editor. Custom Actions Editor displays four nodes (Install/Commit/Rollback/UnInstall). A custom action can be any action that does some task like running scripts, showing windows or any configuration that needs to be done during the installation. To add custom action, right click on the node, select add custom action option, select any dll/exe file. To make the selected dll/exe act as custom action, we need to make it as an installer as shown below.

public class WebInstaller : System.Configuration.Install.Installer {}

The Run time identifies a class as an installer based on the RunInstaller Attribute (System.ComponentModel). The Installer class that you write needs to be inherited from Installer class in System.configuration.Install namespace. The run time calls Install method of installer class during the installation. This method acts as a starting point for the custom action. To pass parameters to the action, CustomActionData property for the custom action needs to be set with required parameters. The following line shows how to pass virtual directory path and port number to custom action.

Custom Action Data = /VDIR=[TARGETVDIR] /PORT=[TARGETPORT]   /// Note
            //: each parameter needs to separated by a space.

Accessing parameters in Custom Action : Context.Parameters["VDir"] /// Context.Parameters is the collection of the parameters passed.

If custom action fails throw an instance of InstallException. This exception will inform the runtime to rollback the installation.

if (Context.Parameters["VDir"] == null)
    throw new InstallException("Virtual directory path not specified");

To provide custom dialog windows, add the particular EXE as custom action. The code attached with this article has an exe as custom action. This exe shows a window prompting username/password and tries to connect to sql server. It also updates web.config file with the connectionstring prepared using user input. It also has some cool code to update IIS to turn off anonymous option for the current virtual directory.

Using the code

The demo zip contains a customized installer. It installs web project creating a virtual directory. After installation, it asks for information to update config file and also updates IIS.

The Source zip contains CustomInstall web project, IISInterface project to update IIS, WebSetup project.


This article caters to the basic requirements of how to customize the installer to show more windows and implement pre/post checks. The key points are creating Custom Actions, passing data to them, aborting installation upon error. Along with these, article also shows how to update config file and IIS settings programmatically.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

United States United States
I am working as Senior Software Designer and Developer for last 3.5 years. I like reading tech articles and writing them, mainly .Net stuff.

I completed MCAD, MCSD.Net, MCSE-Win2k, MCDBA.

You may also be interested in...

Comments and Discussions

Questionusing winform to pass installation path from winform to custom action Pin
aditya_ingle3-Nov-12 10:02
memberaditya_ingle3-Nov-12 10:02 
Questionhow to save virtual directory path and port number to registry Pin
ramamez25-Dec-06 20:31
memberramamez25-Dec-06 20:31 
QuestionHow To: Get TimeSheetInstaller Code Pin
bheinz4-Dec-06 17:18
memberbheinz4-Dec-06 17:18 
GeneralTimesheetInstaller Pin
bhavini prajapati12-Oct-06 21:55
memberbhavini prajapati12-Oct-06 21:55 
GeneralTimesheetInstaller.exe - solution Pin
bdaniel710-Oct-06 1:25
memberbdaniel710-Oct-06 1:25 
Generalcode of time sheet project Pin
jerome@calcmenu.com24-Aug-06 21:37
memberjerome@calcmenu.com24-Aug-06 21:37 
GeneralCustomizing a password field in Web Setup... Pin
petekash24-Aug-06 3:28
memberpetekash24-Aug-06 3:28 
GeneralChanging VDIR parameter [modified] Pin
marquito_cuba3-Jul-06 8:23
membermarquito_cuba3-Jul-06 8:23 
GeneralTimehseetInstaller Project missing Pin
DIKIM30-May-06 0:28
memberDIKIM30-May-06 0:28 
Hi avnrao,
Could you please send me the TimesheetInstaller project source code?
Please send it to

dong-il, Kim
GeneralTimeSheetInstaller Class Pin
kesarisuresh18-Oct-05 2:56
memberkesarisuresh18-Oct-05 2:56 
Questionno volume C -easy solution? Pin
ESCOBAR@@@27-Sep-05 16:07
memberESCOBAR@@@27-Sep-05 16:07 
QuestionSetup Windows en Web Application Pin
Erick J. Tejeda31-Aug-05 10:42
memberErick J. Tejeda31-Aug-05 10:42 
GeneralTimesheetInstaller project Pin
Amarendra Modalavalasa29-Aug-05 14:20
memberAmarendra Modalavalasa29-Aug-05 14:20 
QuestionHow to make items selectable in setup projects? Pin
TLiu-new12-Aug-05 6:05
memberTLiu-new12-Aug-05 6:05 
AnswerRe: How to make items selectable in setup projects? Pin
Anonymous12-Aug-05 12:50
sussAnonymous12-Aug-05 12:50 
AnswerRe: How to make items selectable in setup projects? Pin
raghavagudimetla4-Dec-06 1:56
memberraghavagudimetla4-Dec-06 1:56 
GeneralTimesheetinstaller Pin
Acintha11-Aug-05 23:33
memberAcintha11-Aug-05 23:33 
GeneralRe: Timesheetinstaller Pin
Anonymous12-Aug-05 4:44
sussAnonymous12-Aug-05 4:44 
GeneralRe: Timesheetinstaller Pin
kalph22-Nov-05 20:26
memberkalph22-Nov-05 20:26 
Generalputting file in specific folder Pin
kadnan15-Mar-05 21:07
memberkadnan15-Mar-05 21:07 
QuestionActions before installing? Pin
alforno7-Feb-05 9:47
memberalforno7-Feb-05 9:47 
GeneralCancel installation outside the custom Install class Pin
Lam Ngoc Nguyen1-Jan-05 6:13
memberLam Ngoc Nguyen1-Jan-05 6:13 
QuestionDude, where's my file? Pin
ss__m23-Dec-04 6:49
memberss__m23-Dec-04 6:49 
AnswerRe: Dude, where's my file? Pin
avnrao23-Dec-04 18:08
memberavnrao23-Dec-04 18:08 
GeneralTimeSheetInstaller Project Pin
AlexBoy18-Nov-04 21:20
memberAlexBoy18-Nov-04 21:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171207.1 | Last Updated 11 Jan 2004
Article Copyright 2004 by avnrao
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid