Today I’m writing mostly to those of you who do not consider yourself to be power users. And yet deep down inside you suspect you are (or could be) way more powerful than anyone realizes. I’m not talking about receiving an invitation to Hogwarts, nor about pulling a sword from a stone. Rather, I’m talking about that geeky (and perhaps very lonely) feature on your computer known as the Visual Studio Command Prompt.
I love a good shortcut and I believe this is “healthy laziness”; that is, the urge to find ways to reduce or even eliminate time spent on menial tasks. I want to conserve time and energy for analysis (solving problems in my code), creativity (designing something), or for just being able to get home in time for diner.
Back in the day, I used the command prompt a lot more. When I first started using Windows 3.1, I think I actually recall feeling relieved that I wouldn’t have to boot DOS in order to get work done quickly. There is something so satisfying about blasting through a task, fingers never leaving the keyboard to reach for the mouse. In response, your computer rolls those cool cryptic messages upward across a black window.
Another great example of this kind of bliss can be found by using keyboard shortcuts, the most powerful of which are sometimes obscure. Need a calculator? Press START+R, in the Run dialog box type “calc”, and press ENTER. To maximize the vertical screen real estate of a window in Windows 7 or Windows Server 2008 R2, press START+SHIFT+UP_ARROW. Want to put all the windows away, press START+D. How far can you go in your day without reaching for the mouse? I think this is fun stuff, and it saves wear and tear on my mouse arm and hand.
You don’t have to be an Emacs command-line purist to enjoy the benefits of the command prompt. While I was researching Control Where the Build System Places Your Binaries, I repeatedly needed to test the outcome of a few changes to a few files. For this kind of scenario, you can’t test the outcome of your work locally. Essentially you must:
At first I used only the Visual Studio IDE for many cycles of this task. I started to get tired of having to click through the same UI over and over again. It then occurred to me that I could use the command prompt to save some time.
When you use the IDE to check-in files, you have to open the window, view the files that have changed, make sure they are selected, and then click the button. But when you are repeatedly changing only a few files and you know you simply want to upload them all, you can simply issue this command:
tf checkin /noprompt
Of course, before you do this you should first really be sure that you really know all the files you’ve changed. Not sure? Well, simply type:
tf checkin
to get a list of the files you’ve changed.
Immediately after I checked in my changes, I didn’t even need to leave the command prompt. I simply entered the following command:
tfsbuild start http://contoso-team:8080/tfs/defaultcollection Test "Build My Utilities"
With the tf checkin and the tfsbuild start command invocations stored in the command history buffer, each time I modified a set of files, I was only a five keystrokes away (including the ALT+Tab to switch from the IDE to the command prompt) from testing the latest changes I made.
A few tips that might help if you have not had much experience with the Visual Studio command prompt: