SIGN UP MEMBER LOGIN:    
ARTICLE

Using Installer Classes to Ease Deployment in VS.NET

Posted by Doug Doedens Articles | Visual Studio .NET August 07, 2002
In this article I will demonstrate how to incorporate installer classes with your Visual Studio .NET msi's to handle any supporting tasks that your assemblies may need.
Reader Level:

In the last article I described using Visual Studio .NET to build and deploy your applications.  In this article I will demonstrate how to incorporate installer classes with your Visual Studio .NET msi's to handle any supporting tasks that your assemblies may need.  For example, these installer classes can handle creating MSMQ message queues, creating necessary directory structures, even creating databases that your assemblies rely on.   The idea is to include installer classes with your assemblies and then any one else who needs to use your assembly can simply add your assembly to their MSI project and execute your installer class that will handle all required tasks.

We will begin with the solution we worked with in the first article that can be found here

  1. Right click on the top project named myAssembly and choose Add New Item:



  2. Next choose the Installer Class from the dialog box name it whatever you want and click ok.

  3. You should now have a solution that looks like this



    If you look inside the installer class you will see a lot of Visual Studio .NET created code.   It is best to leave the majority of this code alone and add another call to a function inside the constructor, lets put a function call to WriteToEventLog in the constructor.

  4. Now the installer class should look something like this.



    As you can see the WriteToEventLog entry does nothing but write a message to the event log.  This is obviously a simplistic example in reality you would have the installer class create directory structures, create msmq queues, or some other supporting task that your class requires.

  5. Now click on the Set-up project and navigate to the View Editor Custom Actions as shown below:




  6. You should now see the Custom Actions interface in the IDE you now need to Right Click on the install folder and choose the Add Dialog menu item.   This will bring up the Select Item In Project dialog and you need to double click on the Application Folder icon.  At this point you should have a dialog that looks like the following:





    Click ok and you will see a graphical representation of this action in the IDE.


  7. Now rebuild the entire solution.

  8. Right click on the Set-up project and choose install this will invoke the MSI and allow you to test the Set-up project.  Follow all the way through the installer instructions until the MSI is done installing.

  9. Now check the event viewer and you should see an entry made by the installer class.

    In summary installer classes allow you as an assembly developer to be sure that all the required external tasks are completed when your class is installed.  The developer knows exactly what his/her class needs in order to function properly.  In this simple example I have shown how an installer class is executed inside an MSI.  This example could be extended to handle any number of tasks required in enterprise development.

Login to add your contents and source code to this article
share this article :
post comment
 
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor