Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I sort build output of Visual Studio by Build Order by default?

I know that I could sort the build output of my multicore builds in Visual Studio using the Build Order item in the Output window (as described here).

But once I've done that and hit F7 again, the option switches back to Build and I have to switch back to Build Order again.

Is there a way to set Build Order as default setting in the Output window?

Searching a bit shows me that this question was asked several times but never answered:

  • http://ntcoder.com/bab/2009/06/02/ordering-output-of-out-of-order-builds-in-visual-studio/#comment-484
  • http://blogs.msdn.com/b/zainnab/archive/2010/07/03/show-the-output-window-during-build-vstiptool0045.aspx#comments
  • http://weblogs.asp.net/scottgu/archive/2005/10/21/428094.aspx#1451451

Edit:
The answer given by Simon works for me (or at least it points me to the right direction), but I could not simply copy his code and insert it in my MyMacros project. Instead, I have to create the handler for the build events exactly as described here:

  1. On the Class View explorer pane, in the Macros IDE, double-click the EnvironmentEvents node to display it as an EnvironmentEvents tab and a drop-down menu on the macro editor pane.

  2. From the EnvironmentEvents drop-down menu, select an events type, such as TaskListEvents. The Declarations combo box is now populated with the available Task List events.

  3. On the Declarations drop-down menu, select an event, such as TaskAdded, to add its event procedure to the module.

The event is inserted into your macro and you can now add code to the event procedure.

Otherwise, the event handler isn't called at all.

like image 423
eckes Avatar asked Dec 03 '12 12:12

eckes


1 Answers

You could write a Visual Studio macro, something like this:

Dim WithEvents MyBuildEvents as BuildEvents

Private Sub BuildEvents_OnBuildBegin(ByVal Scope As EnvDTE.vsBuildScope, ByVal Action As EnvDTE.vsBuildAction) Handles MyBuildEvents.OnBuildBegin
    OpenBuildOrderOutputPane()
End Sub

Private Sub OpenBuildOrderOutputPane()
    Dim window As Window = DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput) ' Get Output Window
    Dim output As OutputWindow = CType(window.Object, OutputWindow)
    For Each pane As OutputWindowPane In output.OutputWindowPanes ' Browse panes
        If (pane.Guid = "{2032B126-7C8D-48AD-8026-0E0348004FC0}") Then ' Build Order guid
            pane.Activate()
        End If
    Next
    window.Activate()
End Sub

You need to paste this code in MyMacros, EnvironmentEvents module.

like image 115
Simon Mourier Avatar answered Nov 04 '22 15:11

Simon Mourier