Reader Level:
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.
  • 0
  • 0
  • 56243

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.

COMMENT USING

Trending up