The Visual Studio IDE has an very extensible framework, allowing developers to tap into the inner goings-on of just about anything imaginable that the IDE can do.
Download
VSEvents.txt
This is a small section of code that taps into the IDE build events and performs (for me) two useful functions:
- It stops a solution build as soon as a project fails, instead of plowing through the 50 other projects that are dependent on the failed build but surely won't build themselves. This code has been around for a while, but is still really useful.
Private Sub BuildEvents_OnBuildProjConfigDone(ByVal Project As String, ByVal ProjectConfig As String, _
ByVal Platform As String, ByVal SolutionConfig As String, _
ByVal Success As Boolean) _
Handles BuildEvents.OnBuildProjConfigDone
If Success = False Then 'The build failed...cancel any further builds.
DTE.ExecuteCommand("Build.Cancel")
WriteState(String.Format("Build failed - Build process halted for project {0}", Project))
End If
End Sub
Function GetOutputWindow() As OutputWindow
Return DTE.Windows.Item(Constants.vsWindowKindOutput).Object()
End Function
Function GetActivePane() As OutputWindowPane
Return GetOutputWindow.ActivePane
End Function
Private Sub WriteState(ByVal message As String)
GetActivePane.OutputString(String.Format(message) & vbCrLf)
End Sub
- There is a simple logging feature which captures that start and end times of a solution build, and log them to a file. (Yes, it writes them to C:\ :)). These log files become quite good supporting documentation - as soon as your build times creep over 1 minute, you need these to motivate for a new devmachine.
To make use of these events, as well as adding your own, you'll need to open the Macro IDE (Alt-F11), and paste the contents of the text file into the "EnvironmentEvents" file which you can find if you browse around in the Project Explorer.
Some other macros which I find useful, which come as samples with the VS IDE, are the "SaveView/LoadView" macros. Go to the Macro Explorer (Alt-F8), expand the "Samples" node, expand the "Utilities" node, and double-click on the SaveView macro to run it. The saves the entire window layout for you, which you can retrieve using LoadView. This is great when you temporarily move windows around, or accidentally close windows which you've un-docked.