Click here to Skip to main content
Click here to Skip to main content

Deploying Custom Tool on a developer machine using a Setup Project

, 8 Apr 2009
Rate this:
Please Sign up or sign in to vote.
Making a custom tool work on the developers machine requires several actions like placing keys in the registry and registering your DLL Library using the regasm command. This post will discuss the automation of these procedures using a setup project.

Introduction

Making a custom tool work on the developers machine requires several actions like placing keys in the registry and registering your DLL library using the regasm command. This post will discuss the automation of these procedures using a setup project. For more information on making your own custom tool, visit my post Building a Custom Tool Generator For Visual Studio.

Using the Code

First add a class in your CustomTool Library Project that inherits from the Installer class. In this class, override two methods; the first is the Install method and the second is the Uninstall method. To get the regasm.exe path, you could use the InteropServices.RuntimeEnvironment class to get the runtime directory of the .NET Framework. Then you need to get the assembly location. After that, you could simply start the process of the regasm and pass to it the /codebase parameter and the path of the library.

public override void Install(System.Collections.IDictionary stateSaver)
{
    base.Install(stateSaver);
    string regasmPath = System.Runtime.InteropServices.RuntimeEnvironment.
					GetRuntimeDirectory() + @"regasm.exe";
    string componentPath = base.GetType().Assembly.Location;
    System.Diagnostics.Process.Start(regasmPath, "/codebase \"" + componentPath + "\"");
}

To uninstall, remove the component registration by the /unregister parameter:

public override void Uninstall(System.Collections.IDictionary savedState)
{
    base.Uninstall(savedState);
    string regasmPath = System.Runtime.InteropServices.RuntimeEnvironment.
					GetRuntimeDirectory() + @"regasm.exe";
    string componentPath = base.GetType().Assembly.Location;
    System.Diagnostics.Process.Start
		(regasmPath, "/unregister \"" + componentPath + "\"");
}

The Setup Project

Now make a new setup project and add the output of the CustomTool Library to it. Then Right Click the setup project and select view, then select custom actions.

customactions2

Then Add the CustomTool Project output to the Install and Uninstall Sections as in the image below:

customtoolsetup

OK now you need to add the registry values. Right click on the setup project and then View then select Registry. To add the needed Registry Values, follow the structure in the figure below:

customtoolregistry

Share Your Thoughts

Now all you have to do is just build the setup project and you will have a setup deployment for your custom tool. Please share your thoughts and feel free to drop any comments. Hope you enjoy the project.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

rmostafa
Software Developer (Senior)
Egypt Egypt
Fun Coder Smile | :) My Job is my Hobby Smile | :)

Comments and Discussions

 
GeneralUsing RegistrationServices.RegisterAssembly instead Pinmemberrusso798-Apr-09 8:29 
GeneralRe: Using RegistrationServices.RegisterAssembly instead PinmemberRMostafa8-Apr-09 21:55 

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

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

| Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 9 Apr 2009
Article Copyright 2009 by rmostafa
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid