Jaa


Opening a command prompt for your project

Sometimes while working with a VS.Net project, you need to run a command line tool, either on the sources or output of the project.  VS provides an easy way to add a menu item that will open a command prompt in the target directory of your application, or in the source folder.

In order to enable this, first go to the Tools menu, and choose External Tools.  In the add dialog box, create a new item, and give it a name such as Source Shell.  The command should be cmd.exe.  For initial directory, you can pick one of:

  • $(ProjectDir) - source code for the current project
  • $(SolutionDir) - root directory of the current solution
  • $(TargetDir) - build location of the current project.  This will adjust for different configurations, so it will open a shell in bin\Debug for debug builds, and bin\Release for release builds.

In my copy of VS I have a menu option for Source Shell, opening in $(ProjectDir), and one for Build Shell, opening in $(TargetDir).  I also have a quick script that I run that sets up various environment variables, network drive maps, and drive substitutions, in order for me to have a useful dev command window.  I get this script to run by adding

/k SetDevEnv.cmd

To the arugments line.

Comments

  • Anonymous
    March 22, 2004
    The comment has been removed
  • Anonymous
    March 23, 2004
    Hi Puchi

    What you're looking for is functionality similar to WinDbg's .shell command. Unfortunately there's nothing like that in Visual Studio (at least as far as I know, if anyone has a trick to show how this is done, feel free to post it here). Like you pointed out, adding the "use output window" option only shows the output of the command prompt in the output window, and doesn't let you interact with the prompt. From the VS command window you could run Tools.Shell cmd.exe, but that too will spawn an external command shell.

    -Shawn
  • Anonymous
    March 27, 2004
    It looks like I won't have to make my own command prompt plugin for Visual Studio after all - this feature is included in Visual Studio 2005. Sweet! :) (In the meantime, as a quick substitute you can create External...
  • Anonymous
    March 15, 2006
    The comment has been removed