Hack 77. Master the Visual Studio Command Prompt
command prompt
(VSCP) is a command prompt that loads
environmental settings for Visual Studio and the .NET Framework. What
this means is that you can open the command prompt and type in the command
for a Visual Studio or framework tool, and it will work without you
having to type the full path or navigate to where that tool is
located. (VSCP also sets certain environment
variables, without which many of these tools would not function
correctly.)To use the VSCP, you need to navigate to Start
Files
Studio .NET Tools
(If you are using a different version of Visual Studio, this menu
path will be slightly different.)Figure 10-1 shows an example of the Visual Studio
.NET 2003 Command Prompt.
Figure 10-1. Visual Studio .NET 2003 Command Prompt

various tools you commonly need to use from the command prompt. Some
of the more common utilities that you will use while developing
applications are:
Used to strongly sign assemblies [Hack #54]
Used to add assemblies to the global assembly cache
Used to generate strongly typed DataSets from XML schemas [Hack #49]
Used to view the Intermediate Language code generated by your code
[Hack #63]
Used to generate web services code based on
Web Service Description
Language (WSDL) files
As you can see, a number of useful tools can be quickly accessed
through the Visual Studio command prompt.
10.2.1. Add the Visual Studio Command Prompt as an External Tool
Because of all the helpful utilities available
through the VSCP, you might frequently find yourself opening the
command prompt and then navigating your way to your project or
solution directory. There is a better way. You can add the VSCP to
Visual Studio's Tools menu and have it automatically
open to your project or solution directory:Open the External Tools configuration window through Tools
External Tools.Click the Add button.Set the name to something like:
Visual Studio Command PromptSet the command to:
C:\WINDOWS\system32\cmd.exeSet the arguments to:
\k c:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Toolsvsvars32.batSet the initial directory to any of the available options. (These
include $(SolutionDir) and
$(ProjectDir), which would place you in the
solution directory or project directory, respectively.)Click OK.Figure 10-2 shows an example of the External Tools
[Hack #33] dialog with
these settings entered.
Figure 10-2. External Tools dialog

able to quickly get to the tool and even have it open in the
directory of your choice.
10.2.2. Add the Visual Studio Command Prompt to the Explorer
Another way to get the VSCP at your
fingertips is through a little registry hack that will add an
"Open VS command prompt here"
option in the Windows Explorer. The easiest way to add these registry
settings is to create a .reg in your favorite
text editor with the following code:
Windows Registry Editor Version 5.00You will, of course, need to modify the path to reflect the version
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\VSCP]
@="Open VS Command Prompt Here"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\VSCP\command]
@="cmd.exe /k \"C:\\Program Files\\Microsoft Visual Studio .NET
2003\\Common7\\Tools\\vsvars32.bat\"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Drive\shell\VSCP]
@="Open VS Command Prompt Here"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Drive\shell\VSCP\command]
@="cmd.exe /k \"C:\\Program Files\\Microsoft Visual Studio .NET
2003\\Common7\\Tools\\vsvars32.bat\"
of Visual Studio that you are using and where you have it installed.
Then save the file with a .reg extension. When
you double-click on the .reg file, you will be
asked if you want to add this information to your registry. After
adding this information to your registry, you will then see an option
in Explorer like the one shown in Figure 10-3.
Figure 10-3. Choosing Open VS Command Prompt Here

Explorer and then choose "Open VS command prompt
here" and VSCP will be opened in that directory.The Visual Studio command prompt is a valuable tool, and having it at
your fingertips no matter where you are is very handy.
10.2.3. See Also
Section 13.8Combine
the Visual Studio Command Prompt and the Command
Window" [Hack
#98]