Remapping the Visual Studio F5 Key to Build Solution
I’m writing this mostly as a resource for myself for the next time I need to remember how to do this, but hopefully someone else out there will find it useful.
I’m currently working on a project where I am doing a lot of ASP.Net development. For a couple of very good reasons the development team has decided to configure our development workstations to use the local IIS server that is built into Windows XP rather than working with the web server that is integrated into Visual Studio. I’m starting to really like this workflow, particularly when I’m doing a lot of jQuery or CSS tasks, because I don’t need to wait for the whole project to recompile and launch in Visual Studio’s web server just to check a tiny change.
One thing that I can’t seem to get over is the entrenched reflex to mash the F5 key when I want to test a change. I think it’s just too engrained in muscle memory as part of the test-fix-rebuild cycle I’ve done a million times before. After a couple of months of trying to shift my F5 habit toward using “The Awkward Claw” (Ctr+Shift+B), I decided to change the behavior in Visual Studio to simply trigger a build when I hit F5. Here’s what I did (Note: My team is kicking it old-school and using Visual Studio 2005. You might need to do some translation to follow these steps in other versions of Visual Studio):
In Visual Studio open the Options dialog box (Tools > Options…), expand the Environment group and click on the Keyboard node. In the “Show command containing” text box, type “Debug.Start”. Find the command named “Debug.Start” and select it. Under the label that reads “Shortcuts for selected command:” click the Remove button to unwire the F5 shortcut key.

Now all those inadvertent presses of F5 won’t do anything. This is marked improvement, but we can do better. We can harness all of those uncontrollable left-middle finger reaches to recompile our solution, which is what I want to do 95% of the time anyway.
To wire the F5 shortcut key to the build operation we can use the same section of the Options dialog box. This time we are going to filter the available commands by typing “Build.BuildSolution” into the text box. Find the command named “Build.BuildSolution” and select it. Now in the drop down list under the label that reads “Use new shortcut in:” select “Global”. Put focus in the textbox under the label that reads “Press shortcut keys:’ and press the F5 key and then click the Assign button. The build solution action is now wired up the F5 key.
