HOME | SIGN UP | ACCOUNT | SUBSCRIBE | TROUBLESHOOTING | LOGIN
News · Meetings · Jobs · Downloads · Universal Thread articles · Web articles · Conference coverages · Consultants · Blogs · FAQ · User groups · Photos · Videos

Visual Studio.NET External Tools

David Foderick, Net Knowledge
David Foderick is an independent software developer in Southern California and owner of NetKnowledge, Inc (http://www.netknowledgenow.com). He specializes in Microsoft .NET development tools and languages. David is a frequent speaker at user groups around Southern California and provides corporate training on the .NET platform. He has a Bachelor's degree in Electrical Engineering from the University of Minnesota and is a Microsoft Certified Solution Developer in .NET. Please contact him at netknowledgenow@yahoo.com.

The External Tools feature gives you the ability to add your own tools to the Tools menu. This customization feature can make you more productive in Visual Studio.NET.

Productivity plus...

In Visual Studio .NET, there is a Tools menu that contains, among other things, a list of External Tools as shown below.

Everything between ActiveX Control Test Container through Spy++ is an external tool that you can run right from your development environment. A tool can be any .com, .exe, .pif, or .bat file. The OLE/COM Object Viewer is one of my favorite tools that come with Visual Studio for looking at COM Interop issues. Notice the External Tools... menu item that allows you to configure your own external tools.

Add your own power tools

Note: This rest of this article will use Visual Studio .NET 2003. If you are using Visual Studio 2002, the location of some of the files will be different.

As a simple example of what you can do with the External Tools feature, let's add a menu option that will open up the Windows explorer in your project directory. This is a great timesaver for performing file maintenance functions that cannot normally be done through the Solution Explorer. Select External Tools... from the Tools menu and the following window will display allowing you to maintain your tools.






To add your new tool, do the following:

  1. Click the Add button and enter Windows Explorer as the title.

  2. Enter explorer.exe as the Command. (You may also use the ellipse to browse and find it. Since it is located in your Windows directory you don't have to enter the full path.)

  3. Click the right arrow button after Arguments and select ProjectDirectory from the drop down list. This will add $(ProjectDir) to the text box.

  4. Click Apply and you're done. Now Windows Explorer will show up in your Tools list and you have an easy way to go directly to your project's directory.

Argument List table

Here is the complete list of arguments that you can supply to your tool. These are taken right out of the Visual Studio help file and presented here for your convenience. When you use one of these in Arguments or Initial directory, Visual Studio will expand it to a file or directory name on your hard drive. This feature is what makes External Tools so flexible.

Item Path $(ItemPath) The complete file name of the current source (defined as drive + path + file name); blank if a non-source window is active.
Item Directory $(ItemDir) The directory of the current source (defined as drive + path); blank if a non-source window is active.
Item File Name $(ItemFilename) The file name of the current source (defined as file name); blank if a non-source window is active.
Item Extension $(ItemExt) The file name extension of the current source.
Current Line $(CurLine) The current line position of the cursor in the editor
Current Column $(CurCol) The current column position of the cursor in the editor
Current Text $(CurText) The current text (the word under the current cursor position, or a single-line selection, if there is one).
Target Path $(TargetPath) The complete file name of the target (defined as drive + path + file name).
Target Directory $(TargetDir) The directory of the target.
Target Name $(TargetName) The file name of the target.
Target Extension $(TargetExt) The file name extension of the target.
Project directory $(ProjDir) The directory of the current project (defined as drive + path).
Project file name $(ProjFileName) The file name of the current project (defined as drive + path + file name).
Solution directory $(SolutionDir) The directory of the current solution (defined as drive + path).
Solution file name $(SolutionFileName) The file name of the current solution (defined as drive + path + file name).

Open Dave's toolbox

Let's look at a couple more examples of things that I keep in my toolbox.

The Intermediate Language Disassembler (IlDasm, for short) is an excellent tool for learning the inner workings of .NET and a necessary tool for advanced debugging. It will display the information that goes into the manifest of your assembly and it will also show you the compiled output of your source code. You can add it to your Tools menu with the following settings:

  • Title: ILDASM
  • Command: C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin\ildasm.exe
  • Arguments: $(TargetPath)

When you do this, ILDASM will know to automatically open the correct output assembly for whatever project you have selected in the Solution Explorer. For example, suppose that you have a solution with two projects. One is a Library Project that creates a DLL file and another project in the same solution is a Windows Forms project that compiles to an EXE file. If you highlight any item from the DLL project in Solution Explorer and you run the ILDASM tool from the menu, it will automatically open the DLL file. If instead you are anywhere in the Windows Form project, the same tool will open the EXE file.

Summon the Visual Studio Command Prompt

The Visual Studio Command Prompt is where you get access to all the advanced command line tools. Some examples are:

  • sn.exe for creating strong name keys
  • csc.exe and vbc.exe for compiling source files
  • al.exe for assembly linking
  • gacutil.exe for managing the global assembly cache
  • installutil.exe for installing Windows Services

The environment for using these command line tools is set up in the vsvars32.bat file. Although the installation of Visual Studio will create a link to the Visual Studio command prompt in your Start menu, it will leave you in a starting directory that is not always useful. To run the default version go to Start | All Programs | Microsoft Visual Studio .NET 2003 | Visual Studio .NET Tools | Visual Studio .NET 2003 Command Prompt.

To start the command prompt in a more useful directory you can add it to your External Tools menu with the following settings:

  • Title: VS Command Prompt
  • Command: cmd.exe
  • Arguments: /k ("c:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\vsvars32.bat")
  • Starting Directory: $(TargetDir)

Now when you run the Command Prompt through the Tools menu it will leave you in the same directory where your exe and dll files are, which may be more appropriate for running these command line tools.

More goodies

There are few more things you can do with Tools.

You can define an Accelerator Key for your tool by preceding a letter in the title with an ampersand. For example, a title of &VS Command Prompt will make the V a hot key when the Tools menu is active. You can add a Key Binding to make a shortcut key to your tool. To do this, go to Tools | Options, highlight Keyboard in Environment, scroll down to Tools.ExternalCommand (numbered 1 through 20) in the list to the right. Once you highlight the name of the command that corresponds to your tool, you can enter the keyboard command that will run your tool. Press the Assign button to complete the keyboard assignment. The completed process is shown below.

Getting back to the External Tools configuration windows, there are a couple of more options. If you want to pass a different parameter to your tool each time you run it, check off the Prompt for Arguments option and Visual Studio will prompt you for the arguments.

If your tool writes to the standard output, you can have the output display to the Visual Studio Output window instead of a separate DOS window by checking off the Output to Window option. The documentation says that this option is only available for .bat and .com files, but I see that that it is also selected for the Dotfuscator tool (Dotfuscator.exe).

Summary

The tips presented in this article can save you the frustration of fumbling around your hard drive looking for the directories and files that belong to your project. External Tools give you easy access to your developer tools, providing the "Integrated" features in the Integrated development environment. For even more control over Visual Studio, look into the Visual Studio macro features.

Resources:

David Foderick is an independent software developer in Southern California and owner of NetKnowledge, Inc (http://www.netknowledgenow.com). He specializes in Microsoft development tools including .NET and Visual FoxPro. David is a frequent speaker at the Los Angeles C# Developers Group and provides corporate training on the .NET platform. He has a Bachelor's degree in Electrical Engineering from the University of Minnesota and is a Microsoft Certified Solution Developer in .NET. Please contact him at netknowledgenow@yahoo.com.

More articles from this author

NoTitleDate
1..NET Code Access SecurityAugust 2003
2..NET Events SimplifiedFebruary 2003
3..NET Message QueuingJuly 2003
4.Add a Print Screen function to your .NET applicationJanuary 2003
5.Strings and the .Net StringBuilder ClassApril 2002
6.What is a Type?April 2003
7.Why ADO.NET is not Object-orientedOctober 2003

Copyright © 1993 - 2014 Level Extreme Inc., All Rights Reserved · Telephone: 506-783-9007 Email: info@universalthread.com · Privacy & Security · Copyright · Terms & Conditions