Article Options
Recently Viewed
Premium Sponsor
Premium Sponsor

 »  Home  »  Deployment  »  Installer Class and Custom Actions
Installer Class and Custom Actions
by Arnaldo Sandoval | Published  10/15/2007 | Deployment | Rating:
Arnaldo Sandoval
I began my run in the IT field back in 1975 while at the University getting my Industrial Engineer Bachelor Degree; using Wang Basic language and Burroughs 6700's FORTRAN and COBOL, working as a Teacher’s assistance for a fist full of dollars, since then I had worked in four different countries: Venezuela, USA, Mexico and Australia, the Business Basic Language the main skill expected from me; learning Unix, C, PASCAL, Uniplex, WordPerfect, 20/20 in the lates 80s, Sybase in the early 90s, Basis BBx in the 90s, Microsoft’s VBA in the mid 90s, Visual Basic version 3.0 around 1996; moved to Australia in the lates 90s, here I kept learning, Transoft’s Universal Business Language, Oracle, Microsoft SQL Server, Visual Basic .Net; working for a major Australian company in the building material market. I had worked for Computers Manufacturing companies (MAI Basic Four after reading the Wikepedia definition, it feels good being an active part of the industry), and high rollers companies (DOLE, Pepsico when they operated Pizza Hut, KFC, Taco Bell and PFS, Boral Limited), roaming the world while doing so, exposed to cutting edge technologies of their time, creating it when the opportunity required so. I currently look after an Oracle data warehouse, sourcing its data from four or five legacy applications, servicing Crystal Reports and Cognos Cubes, developed VB and Net solutions; I could claim the phrase “I had been there, done that” suits me like a globe, always addressing any challenge with an engineer mind, which is different to an IT mindset.  

View all articles by Arnaldo Sandoval...
Page 1

INTRODUCTION

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

Setup and Deployment Projects can reference as many Installer Classes as required. the Installer Class could be part of your own application's class collection or a stane alone DLL. It will be up to the developer and his/her organization rules to decide how to develop and deploy installer classes.
 
SCOPE

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.

REQUIREMENTS

It will be nice if you have Visual Studio 2005, and a project you want to deploy in order to practice the concepts covered by this document, as well as Virtual PC. Keep in mind that in the early stages of learning how to use Installer Classes you could create a crippled deployment package, which will never install or uninstall.

TERMINOLOGY

  • Target Machine is the PC or workstation your project will be installed on.
  • Developer Machine is your PC, the one you use to develop your solution and create a deployment project.
  • Setup and Deployment Projects are specialized projects that install your solution on a target machine.
  • Custom Action an external process written by the developer that is run by the deployment project at installation time when the installation is about to finish.
  • MSI Microsoft Installer file, this files are generated by the Setup and Deployment projects.

HOW TO CREATE AN INSTALLER CLASS

  1. Create a new project using the Class Library template, the project name for this procedure will be MyInstallerClassDll



  2. Add a new Installer Class to the project MyInstallerClassDll by clicking on Project, Add Class, select the Installer Class template, you may enter any name, the name we will use in this procedure is MyInstallerClass.

Your IDE should look like the one shown below:

 
 

 

Comments    Submit Comment

Comment #1  (Posted by jipfromparis@hotmail.fr on 10/23/2007)
Rating
Very instructive. Just a point, its always a good idea to take globalization into account. Network service account name is OS language dependent. Thus, on page 4, the first parameter for FileSystemAccessRule constructor should be :

new SecurityIdentifier(WellKnownSidType.NetworkServiceSid, null).Translate(typeof(NTAccount)).Value

The above line requires using the System.Security.Principal namespace. This said, thanks again for this article.
 
Comment #2  (Posted by an unknown user on 11/20/2007)
Rating
Great! Short but detailed. Thanks
 
Comment #3  (Posted by an unknown user on 11/21/2007)
Rating
Good One.
 
Comment #4  (Posted by Gil Yoder on 11/29/2007)
Rating
Just what I've been looking for! You won't believe how hard it was to find a good explanation of customer actions. Thanks!
 
Comment #5  (Posted by Iván Gracia on 12/14/2007)
Rating
Hi! Great article! Came across it while searching for a way to include a custom action that asks the user whther he wants to empty the install folder or not on uninstall. Is possible to do this with Orca? How can I add a custom action to an installer project, but only the uninstall part?

Thanks in advance!
 
Comment #6  (Posted by Arnaldo Sandoval on 12/14/2007)
Rating
Hi Ivan, it seems the answer to your question is on page 3, you can assign the custom action to the UnInstall action; if you want to talk about it, why don't you join VbCity (www.vbcity.com) and post a question there. I will be glad to help; my user name there is rock.

Cheers,
 
Comment #7  (Posted by Jimmy Huang on 12/25/2007)
Rating
Very useful
 
Comment #8  (Posted by an unknown user on 12/28/2007)
Rating
It was a brilliant explanation. Before this article I didn't understand how it worked, and I couldn't find a good explanation anywhere else.
 
Comment #9  (Posted by an unknown user on 01/15/2008)
Rating
Trapping the mouse within the form seems like a hack which will not work in all cases. Any other ideas?
 
Comment #10  (Posted by Arnaldo Sandoval on 01/15/2008)
Rating
I agree with you regarding the issue with the mouse, and the way it is handled; I had two options at the time I wrote the article (a) make the community aware of the problem, giving a possible workaround or (b) exclude any reference to the odd behaviour, which will frustrate those following these directions; I think that option (a) better services the community, if anyone knows a better way to resolve the mouse issue, please post the code or email it to me, I will gratefully amend the article with a recognition note to the person assisting me with the issues.
 
Comment #11  (Posted by Andrei on 01/28/2008)
Rating
I can use following parameters:

[TARGETDIR]
[TARGETVDIR]
[TARGETPORT]

But I need to pass Product Name. It this possible? If so, which parameter I should use?
Thank you.

 
Comment #12  (Posted by willfread on 01/29/2008)
Rating
great Article ...The way he/she present the Topic
 
Comment #13  (Posted by an unknown user on 01/30/2008)
Rating
Just what I was looking for! Step-by-step, very complete and very easy to follow. Great article!
 
Comment #14  (Posted by Tomek on 02/07/2008)
Rating
great article

really great
 
Comment #15  (Posted by Tom on 02/08/2008)
Rating
This is the most helpful thing I've found on custom actions. Thanks.
 
Comment #16  (Posted by an unknown user on 02/10/2008)
Rating
It gives through knowledge of installer class and it's uses
 
Comment #17  (Posted by Blumen on 02/17/2008)
Rating
Great article! Very useful indeed!!
 
Comment #18  (Posted by Mustafa on 02/22/2008)
Rating
Thanks for the great post.. That covers many points and details of installation and uninstallation, thanks again..
 
Comment #19  (Posted by Greg Askew on 03/02/2008)
Rating
Thank you for writing this article, it is very helpful!
 
Comment #20  (Posted by an unknown user on 03/15/2008)
Rating
Excellent and many thanks. This article really helped. A section on how to add shortcuts into the start/programs menu along with the application's icon (non default) would be a great addition.
 
Comment #21  (Posted by an unknown user on 03/17/2008)
Rating
I was able to create a custom install package with limited experience.
 
Comment #22  (Posted by an unknown user on 04/18/2008)
Rating
bcas it has the more detailed and helpful info than the other articles on the net have..
 
Comment #23  (Posted by ducnm on 04/25/2008)
Rating
Great article, but I have a problem. When I unistall program, i want it not delete some file in directory. How do you do?

 
Comment #24  (Posted by Mayank Kukadia on 04/29/2008)
Rating
Greate article. Greate Efort. Thanks a lot.
 
Comment #25  (Posted by Geof on 05/06/2008)
Rating


hi,
first, sorry for my english…
I have made an Installer Class, it works, but my trouble is when the user want to stop the installation, it doesn’t stop… I have a message, but the installation goes on.
I have made method override for “RollBack” , but the programm doesn’t get in on clicking Cancel_Button.
How can I made for stopping or calling the rollback method, when the Cancel_Button is clicking?
thanks

 
Comment #26  (Posted by Arnaldo on 05/07/2008)
Rating
Hi Geof,

Why don't you join www.vbcity.com and post your question there, it will be easier to assist you this way, it will not be practical to engage into a technical discussion inside these comments, once your issue is resolve we can post a link to the VbCity's thread.

Regards,
Arnaldo
 
Comment #27  (Posted by an unknown user on 05/07/2008)
Rating
Fantastic effort thank you for that. That helped me a lot.
 
Comment #28  (Posted by liza on 05/19/2008)
Rating
nice work man 10x
 
Comment #29  (Posted by an unknown user on 05/23/2008)
Rating
A god send. Thank you
 
Comment #30  (Posted by cYVDGniuEhZfFWK on 06/05/2008)
Rating
tickets_5.txt;2;2
 
Comment #31  (Posted by an unknown user on 06/11/2008)
Rating
Superior! I have been searching for days for a useful article on customized setup/deployment projects and this is the only one I found that really explains it well with excellent working examples. All I wanted to do was add a dialog to ask for a product key and verify it. I saw all the referenced MSDN articles, but to me they were virtually worthless. Thanks for putting it all together and identifying the quirks.
 
Comment #32  (Posted by an unknown user on 06/11/2008)
Rating
Superior! I have been searching for days for a useful article on customized setup/deployment projects and this is the only one I found that really explains it well with excellent working examples. All I wanted to do was add a dialog to ask for a product key and verify it. I saw all the referenced MSDN articles, but to me they were virtually worthless. Thanks for putting it all together and identifying the quirks.
 
Comment #33  (Posted by an unknown user on 07/10/2008)
Rating
Super Article
 
Comment #34  (Posted by an unknown user on 07/17/2008)
Rating
Neat Explanation
 
Comment #35  (Posted by Val on 07/18/2008)
Rating
Excellent article! Could you please restore the broken links for the images? I need also more information about the COM registration of the main assembly. Let's say that the installer class is part of the main assembly which is designed to be registered as COM. Is there is no custom action, the setup takes care of that. But now that there is a custom Installer Class, should I

(a) uncheck "register for COM" in the setup and keep the registration portion in the Installation Class,
(b) check "register for COM" in the setup and remove the registration portion in the Installation Class, or
(c) keep the COM registration in both places?

I tested them all and it did not ,atter one way or another. Just wonder whether there are cases when a particular scenario should be preferred.
 
Comment #36  (Posted by an unknown user on 07/21/2008)
Rating
Hi Val,

All the article's images seem ok to me, could it be possible your network connection or ISP got something to do with your issue.

Regarding your COM question, I am afraid I wont be able to help as my experience with COM is limited, although it seems your worked it out very well.

The article is a guideline for developers, sharing some knowledge with the community at our best of capabilities, sometimes our knowledge is limited.

Arnaldo
 
Comment #37  (Posted by an unknown user on 07/24/2008)
Rating
What a great article!
 
Comment #38  (Posted by nick on 07/27/2008)
Rating
R018d9 hi! hice site!
 
Comment #39  (Posted by nick on 07/29/2008)
Rating
aWTjUO hi! hice site!
 
Comment #40  (Posted by nick on 07/29/2008)
Rating
aWTjUO hi! hice site!
 
Comment #41  (Posted by an unknown user on 08/04/2008)
Rating
Awesome!!! Right information at right time.
 
Comment #42  (Posted by an unknown user on 08/07/2008)
Rating
It's very useful to me
 
Comment #43  (Posted by bob on 08/16/2008)
Rating
cool post dude
 
Comment #44  (Posted by Asher on 08/21/2008)
Rating
Grate! well done!
 
Comment #45  (Posted by an unknown user on 08/29/2008)
Rating
The article explains almost all the Things that VS Installer Proj can do.
 
Comment #46  (Posted by an unknown user on 09/09/2008)
Rating
Learned alot about the process of developing custom actions.
 
Comment #47  (Posted by an unknown user on 09/12/2008)
Rating
Me ha ayudado bastante. Gracias
 
Comment #48  (Posted by judoka on 10/12/2008)
Rating
become famous -- and I hope you became richer, too! ,
 
Comment #49  (Posted by anoop on 10/14/2008)
Rating
Superb
 
Comment #50  (Posted by an unknown user on 10/16/2008)
Rating
Excellent! After fruitless hours trawling for a decent guide to installer classes I finally found one, your efforts are greatly appreciated.
 
Comment #51  (Posted by joseph on 10/19/2008)
Rating
interesting site man
 
Comment #52  (Posted by an unknown user on 10/24/2008)
Rating
Perfect!
 
Comment #53  (Posted by Alex on 11/25/2008)
Rating
the Best
 
Comment #54  (Posted by an unknown user on 02/15/2009)
Rating
Excellent article!
 
Comment #55  (Posted by an unknown user on 04/01/2009)
Rating
wow, great article
 
Comment #56  (Posted by Ramesh on 04/07/2009)
Rating
hi,

can u tell me how can i create the license key for an application?
 
Comment #57  (Posted by an unknown user on 04/16/2009)
Rating
Great article thanks
 
Comment #58  (Posted by an unknown user on 05/04/2009)
Rating
A straightforward explanation of the setup and deployment capabilities. Reading this article is a good starting point for anyone who wishes to customize the installer behaviour. Thank you, it helped me a lot!
 
Comment #59  (Posted by Gaizzy on 05/04/2009)
Rating
Excellent article though, one of the unwritten rule is if the 'DetectNewerInstalledVersion' property is set to 'false' then the Uninstall event will never fire hence you will be able to override the Uninstall method but nothing will work.
 
Comment #60  (Posted by an unknown user on 06/02/2009)
Rating
Nice and clear. Thanks
 
Comment #61  (Posted by an unknown user on 06/12/2009)
Rating
Comprehensive information about CustomActions. Up to now in vain afterwards gesuch, finally found! Thank you!
 
Comment #62  (Posted by Arshu on 07/27/2009)
Rating
best article about custom actions found so far.
Needs some help. My application is running in system tray and can able to run the application even after my MSI uninstall. How can i make my MSI using custom actions. Idea please?
 
Comment #63  (Posted by an unknown user on 08/18/2009)
Rating
good material
 
Comment #64  (Posted by an unknown user on 08/19/2009)
Rating
Great article! You made my life a lot easier. It was very difficult to find any useful information dealing with custom actions that was actually well detailed.
 
Comment #65  (Posted by Sonali on 09/08/2009)
Rating
Excellent Article!!! Thanks.
 
Comment #66  (Posted by an unknown user on 09/17/2009)
Rating
www.spiritssoft.com

www.kamadhenucollege.com

www.spiritssoft.com
 
Comment #67  (Posted by an unknown user on 09/23/2009)
Rating
Thanks a lot.... Greatly Appreciated
 
Comment #68  (Posted by on 10/11/2009)
Rating

 
Comment #69  (Posted by an unknown user on 10/20/2009)
Rating
A detailed,step by step appraoch
 
Comment #70  (Posted by an unknown user on 10/28/2009)
Rating
Hi,
After goggling lots of of pages on site I found something very interesting and useful.Thanks for such a wonderful article.
Minakshi
 
Comment #71  (Posted by Minakshi Juware on 10/28/2009)
Rating
Hi,
I have successfully implemented this method for launching the custom condition before installing the actual application.It works fine.
Thanks for this, it helps me lot.
Minakshi Juware
 
Comment #72  (Posted by an unknown user on 11/02/2009)
Rating
Very confused article
 
Comment #73  (Posted by water-soluble and they are renally excreted. on 11/25/2009)
Rating
See you...Thanks, its great to receive such positive comments.: URLsWithHREF
 
Comment #74  (Posted by Grunenthal has promoted it as an opioid with on 11/27/2009)
Rating
Thanks for taking a few of us.: URLsWithNothing
 
Comment #75  (Posted by an unknown user on 12/01/2009)
Rating
Great article.
One question: Any way to delete files that are 'temp'?

Also, the values you can put in 'condition' don't seem to the easily found. Maybe a list or reference would be helpful
 
Comment #76  (Posted by dpeneireiro on 12/14/2009)
Rating
Why there are not all the pictures?
Can someone post them?
thank's
 
Comment #77  (Posted by an unknown user on 12/18/2009)
Rating
Good but hopeless
 
Sponsored Links