Programmatically Add External Tool to Visual Studio

I tried to find some information on adding an External Tool to Visual Studio using a Setup Project, and came across this Social.MSDN entry.

While it deals with Visual Studio 2005, the information can easily be modified to work in later versions of Visual Studio.

In your Setup Project’s Registry View, add the following keys:

For Visual Studio 2005

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\External Tools\

For Visual Studio 2008

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\External Tools\

For Visual Studio 2010

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\External Tools\

Below each External Tools key, add a key identifying your tool.

Under the key for your tool, you need to add ALL values (from MSDN above):

“ToolArg”=”$(ItemPath)”
“ToolOpt”=dword:00000008
“ToolCmd”=”notepad.exe”
“ToolDir”=”$(TargetDir)”

The flags that can be or’ed together in “ToolOpt” are the following:

#define TOOLOPT_ISAPPGUI      0x01
#define TOOLOPT_CLOSEONEXIT   0x02
#define TOOLOPT_PROMPTFORARGS 0x04
#define TOOLOPT_USEOUTPUTWIN  0x08
#define TOOLOPT_SAVEALLDOCS   0x10
#define TOOLOPT_USETASKLIST   0x20
#define TOOLOPT_UNICODE       0x40

Note that Setup Project expects decimal notation for DWORD values.

At first, my tool was not displayed because I did not provide the ToolDir value as it is not relevant for execution.

Providing all the values displays the tool’s menu as disabled (grayed).

Opening the External Tools dialog and clicking OK enabled to entry for my new external tool.

4 thoughts on “Programmatically Add External Tool to Visual Studio

  1. Pingback: Minor Update of VS Solution Dependency Visualizer « devioblog

  2. Pingback: External Tools in Visual Studio 2017 and higher | devioblog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.