Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Deploying Custom Tool on a developer machine using a Setup Project

0.00/5 (No votes)
8 Apr 2009 1  
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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here