Click here to Skip to main content
15,892,927 members
Articles / Programming Languages / C#

Deploying Custom Tool on a developer machine using a Setup Project

Rate me:
Please Sign up or sign in to vote.
3.50/5 (3 votes)
8 Apr 2009CPOL1 min read 21.9K   12   2
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.

C#
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:

C#
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)


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

Comments and Discussions

 
GeneralUsing RegistrationServices.RegisterAssembly instead Pin
russo798-Apr-09 8:29
russo798-Apr-09 8:29 
GeneralRe: Using RegistrationServices.RegisterAssembly instead Pin
rmostafa8-Apr-09 21:55
rmostafa8-Apr-09 21:55 
Yeah, Thanks I've just wanted to show an alternative by running the regasm.exe file.

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

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