Monday, March 28, 2005

Opening a command prompt for your project

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.

No comments: