Friday, October 19, 2007

Visual Studio 2005 Setup and Deployment Installer Classes and Custom Actions

DevCity.NET - Installer Class and Custom Actions

"Installer Classes are great tools that you can develop and integrate with your Setup and Deployment Projects in order to perform additional tasks while running any application's installation or un-installation process, thru its MSI file.
Visual Studio .Net supports for Installer Classes dates back to the .Net Framework 1.0 (VS.Net 2002) This article focuses in its latest incarnation within VS.Net 2005.

An Installer Class contains code written by you that takes care of many things required to properly install your application on the end user's Target Machine; you can write an Installer Class using your favourite development language, i.e. Vb.Net, C#, C++, etc; this article's examples are written in C#.

There are very few limitations of the things an Installer Class could do. Perhaps the developer's knowledge imposes the major constraints (or the author's as we don't claim to know everything); the list below includes many of the things an Installer Class is able to do:

  • Change folder permissions.
  • Run your application after installation.
  • Create folders required by your application.
  • Update the application's config file with installation time parameters.
  • Send emails.
  • Write entries to the Target Machine's eventlog.
  • Install database schemas.
  • Windows Services (which, if we follow the existing procedures to deploy them, we are using Installer Classes already).
  • etc, etc, etc

...

This document is based on VS.Net 2005 deployment projects, explaining as much as possible about Installer Classes and their integration to Setup and Deployment project's Custom Actions.; There are not too many differences between Setup and Deployment projects between Visual Studio 2003 and 2005, and based on this we may claim the information found on this article should help you to implement Installer Classes using Visual Studio 2003.

The document contains the following sections:

  • Requirements
  • Terminology
  • How to create an Installer Class
  • Un-written rules
  • Unpleasent features
  • Using these events (about Installer Class events)
  • Using the Commit event to change the target directory permissions.
  • Using the Uninstall event to clean the target directory
  • Where is the "NT AUTHORITY\SERVICE" account coming from?
  • Exceptions and Exception handling in your installer class.
  • Adding user interfaces (forms) to your installer class.
  • Launching your application after installation.
  • Conclusions.
  • References.

..."

This is a six "page", medium level document on installer classes and custom actions, taking you all the way from adding an Installer Class, responding to install events, adding custom UI, to seeing it in the finish MSI.

I don't use Installer Classes all that much and when I do it's usually to the bare minimum (i.e. like when installing services, etc).

This article has given me a new appreciation for what can be done with them...

2 comments:

Unknown said...

i want to prevent uninstall a program when it is running.i want to do it by custom action in visual studio setup and deployment.can you help me?

Greg said...

Sorry, but that's not something I've done before...