Add an External Tool

Add an External Tool

Enhance Visual Studio by plugging in all kinds of external tools such as ILDASM.

Visual Studio provides the functionality to include external tools in the Tools menu. If you go to the Tools menu, you will see a listing of tools including those like Error Lookup and Create GUID. These are all external tools that have been configured to be listed in this menu. You can modify the existing external tools and add your own external tools to this list quite easily.

To modify the existing tools or to add new tools of your own, you simply need to go to Tools External Tools. You will then see the dialog shown in Figure.

External Tools dialog

This dialog lists all of the tools currently configured in Visual Studio. You can use the Move Up and Move Down buttons to rearrange the order of these tools in the menu. You can also click on each of the tools and modify any of its properties or use the Delete button to remove a tool from the menu.

You can add a new external tool by clicking the Add button. This will clear out all of the fields and allow you to enter new values and save a new external tool. In this example, I am going to add a link to the tool ILDASM. ILDASM is a tool that can be used to examine the IL of an assembly [Hack #63] .

Following are the steps to add ILDASM as an external tool:

  1. Click the Add Button.

  2. Specify a Title of ILDASM.

  3. Specify a command location of C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin\ILDASM.exe (this path may vary depending on the version of Visual Studio you are running).

  4. Click on the arrow to the right of the Arguments box and choose Target Path. This will send the complete path of your assembly to ILDASM.

  5. Click the OK button.

ILDASM will now be added as an external tool to the Tools menu. You can click on the ILDASM link and the tool will open with your assembly already loaded in the tool. Adding external tools for utilities that you commonly use is a great way to save time and avoid the hassle of pointing the tool to your assembly or file.

External Tool Arguments

In the ILDASM example, I used the Target Path argument to pass the name and location of the project's assembly to the external tool. The 15 different argument variables that you can use when configuring an external tool are listed in Figure.

External tool argument variables




Item Path


The path to the active document.

Item Directory


The directory where the active document is located.

Item File Name


The name of the active document.

Item Extension


The file extension of the active document.

Current Line


The line position where the cursor is currently resting.

Current Column


The column position where the cursor is currently resting.

Current Text


Either the word where the cursor is located or a single line of selected text.

Target Path


The path (including filename) to the current target. (The target is what your project is compiling into, e.g., the assembly.)

Target Directory


The directory where the target is.

Target Name


The filename of the target.

Target Extension


The file extension of the target.

Project Directory


The drive and directory where the current project is located.

Project File Name


The complete path to the current project.

Solution Directory


The drive and directory where the current solution is located.

Solution File Name


The complete path to the current solution.

Using these variables, you can pass all kinds of information directly to your external tool, saving you the time of supplying this information by hand.

You can also set the initial directory where this tool should be run. This is set using the Initial Directory option. The initial directory can be set to Item Directory, Target Directory, Target Name, Project Directory, or Solution Directory. (These arguments are the same as the arguments defined in Figure.)

External Tool Options

A number of options can also be set when configuring external tools:

Use Output Window

When this option is enabled, any response from the command line will be shown in the output window. If you were calling a command-line utility that reported statistics on your assembly, instead of having to view the results in the open command prompt, you could have those results shown in the output window. [Hack #65] includes an example of doing this with the FxCop command-line utility.

Prompt for Arguments

When this option is enabled, you will be prompted every time the tool is run and allowed to modify or change the arguments being passed to the external tool. A good example of when this might be useful is when you have a tool to which you want to pass the project, solution, or item path, depending on the circumstances. By prompting you each time, it allows you to choose which argument you want to pass into the tool.

Close on Exit

This option determines whether the command prompt will be closed after your command has been executed. Normally this will be set to true, but if the tool you are calling returns results in the command window, you would not want it to close. This option is also very handy when debugging an external tool that is not working, since you can see the error it returns.

Adding and configuring external tools is a great way to customize the IDE and can save a lot of time that would otherwise be wasted looking for programs and pointing them at your assemblies or files .

     Python   SQL   Java   php   Perl 
     game development   web development   internet   *nix   graphics   hardware 
     telecommunications   C++ 
     Flash   Active Directory   Windows