Visual Studio Keyboard Shortcuts for Compiling (MSDN Flash - Dec. 29, 2008)
There is not much point in writing code if you can't compile it so, in this edition's keyboard shortcut tips and tricks, we are going to discuss compiling your code. For both Visual C# and Visual Basic schemes, you can compile the entire solution using Ctrl+Shift+B. However, three keys (requiring two hands and an elbow) is a little unfriendly for what should be a relatively frequent operation. Fortunately, the Visual C# scheme also allows F6 for the same activity and you could map the same key for Visual Basic (unless splitting the window is a frequent occurrence for you :).
This works well when you only working with one or two projects in a solution, but what about when you solutions has 20+ projects in (a common occurrence if you have test projects for each production assembly). Fortunately, you can use Shift+F6 (in the Visual C# scheme) if you only want to compile just the current project. A great way to check for compilation issues on recent changes - perhaps removing squiggles that are not cleared up by the just-in-time compiler (an issue considerably reduced in Visual Studio 2010).
Another useful build related keyboard shortcut in the Visual C# scheme is Ctrl+Break. This shortcut cancels the currently executing build - a useful command, especially when a single syntax error is generating a plethora of errors and you want to go back and fix it quickly.
For those of you with one of the Visual Studio Team System SKUs that included code analysis, there are are commands for running it. Visual Studio Team System's code analysis analyzes the compiled assemblies for suspicious code (a bad code smell) and then flags the issue using a warning. (I have found this to be invaluable for my team in automatically catching issues even before the point of code review - frequently issues that are hard to spot with the naked eye.) You can turn on code analysis within the project properties:
However, there are two potential issues. Firstly, turning on code analysis adds noticeable time to you build - this is worth it before checkin, but sometimes a distraction from the task at hand. Secondly, warnings in dependent projects will no longer appear in an incremental build, causing them to be lost until you perform a rebuild all. One work around for both of these is to assign a keystroke to code analysis (perhaps Ctrl+Alt+F6):
One more minor note: If you install VMWare 6.5, it will re-map F6 to "Start debugging in a virtual machine," causing an "Unable to detect the current startup project" error dialog to appear. To correct this, re-map F6 back to Build.BuildSolution.
Posted for MSDN Flash: Keyboard Visual Studio Tips & Tricks for Dec 29, 2008
Saturday, December 20, 2008 7:16:19 AM (Pacific Standard Time, UTC-08:00)