Posted by Garry Shutler
Something I’ve found myself needing to do more recently is open a command prompt at the root directory of my solution. Often this is to run a rake task or something like that.
The way I used to do this was rather long winded, but now I’ve got it down to a single key combination and I’ll explain here how you can do the same.
Firstly, open up the external tools dialog in Visual Studio:
Then add a new tool:
This will give you a prompt to type the details of the new tool into:
Then fill in the details of the new tool. We want to point this at cmd.exe which is usually located in your System32 directory. You also want to set the initial directory to the solution directory:
I have then moved the tool up the list just because I like it being higher. The position of the tool in the list only makes a difference when setting up a keyboard shortcut as I will explain in a minute:
Once you’ve filled in all the details and moved the tool to the position you want it in just click Ok. You will now see that the tool you just created appears in the external tools section of the tools menu:
Now we can set up a keyboard shortcut for the new tool. Firstly, open the options dialog:
Then go to the keyboard section:
Then type in the command name “Tools.ExternalCommandX” where X is the number your tool appears in the list. Mine is second so I type “2”:
Then assign a key combination to this command. I chose Ctrl+Shift+Alt+C:
Then click ok and you will now be able to open a command prompt at the root of the current solution with your key combination.
This principle can be extended to call any program, you may have noticed I use it to call the default rake task for my solution.