The Darkside

Shedding light on things and stuff

 
  Home :: Contact :: Syndication  :: Login
  83 Posts :: 0 Stories :: 57 Comments :: 2 Trackbacks

Ads

 

Donate via PayPal...

...if you feel the site helped.

Archives

Post Categories

Open Source Projects

Other Blogs

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.

posted on Wednesday, January 23, 2008 7:50 AM

Feedback

# re: Visual Studio IDE Events - Tips and Tricks 2/28/2008 12:06 PM Fry
27 Feb 2008 13:08:03, 29.375, 9254.1516613000
27 Feb 2008 14:09:55, 7.234375, 9261.3860363000
27 Feb 2008 14:10:32, 19.203125, 9280.5891613000
27 Feb 2008 14:11:06, 6.734375, 9287.3235363000
27 Feb 2008 14:11:55, 1.296875, 9288.6204113000
27 Feb 2008 14:12:06, 38.65625, 9327.2766613000
27 Feb 2008 14:13:13, 98.765625, 9426.0422863000
27 Feb 2008 14:15:27, 95.265625, 9521.3079113000
* 27 Feb 2008 14:21:45, 119.828125, 9641.1360363000

9641 secs in the last 20 days.... 2.6 hours of my life wasted!

# re: Visual Studio IDE Events - Tips and Tricks 2/28/2008 6:49 PM Darksider
Glad you find this little macro useful - the results are a clear indication that you need to get a faster machine.

Side Note: Another interesting observation from your data is that you seem to be compiling once a minute (and possibly that you have lunch from 13:00 to 14:00) :)

Comments have been closed on this topic.