BlockLeftTop, PRELOAD BlockLeftBottom, PRELOAD BlockLeftStretch, PRELOAD BlockTop, PRELOAD BlockBottom, PRELOAD BlockStretch, PRELOAD BlockRightTop, PRELOAD BlockRightBottom, PRELOAD BlockRightStretch, PRELOAD
DeltaEngine

Collapsing Projects in Visual Studio Solutions

by Benjamin Nitschke 13. January 2010 11:09

DeltaEngine VS Collapse

If you have 50+ projects in a single solution it can be annoying that you cannot collapse them all with a single click or keystroke. Expanding everything can be simply done with Numpad * at any node in the solution explorer. Having so many projects in a solution and compiling them all everytime you F5 something is not such a good idea because compile time goes through the roof (even though each single project is compiled really quickly, usually in much less than a second). Please note that our projects are mostly very simple and having so many projects is by design because they only implement certain features and can be easily replaced (or there are several modules for the same feature, just doing differently or for different platforms). We should blog about that too, I think it is a pretty good idea and makes refactoring and multiplatform development much easier than big projects and lots of ugly defines (we have almost no defines right now and are pretty happy with it).

 

To solve this we have a little helper tool that recursively selects the projects you need for any given project you want to work on, then you end up with 3-4 projects instead of 50+ (we have like 10-20 new projects every month, so this will probably increase for a while). An alternate solution is to fiddle with the build settings in the Configuration Manager to just compile some projects, but not the rest. But this is very error prone and can cause many headaches because you forgot to compile some project you changed some little thing and then your code will still execute the old .dll with the old code missing your newly implemented functionality.

 

But the problem with so many projects, and usually in any kind of Visual Studio solution, is that you cannot easily collapse all projects at once. Instead you have to collapse them one by one, which can be fun with 5 projects, but it is certainly not funny with 50+ projects anymore and you practically have to do it every day to keep the solution explorer short and tidy. Luckily some clever people solved this problem many years ago with macros or extensions and I like the simple macro version. There is a great tutorial with all required steps available, which you can use to set it up for your Visual Studio. We use a slightly modified macro that works better with our sub folders that have projects too:

 

Imports System
Imports EnvDTE
Imports System.Diagnostics

Public Module Collapse
    Sub CollapseAll()
        ' Get the the Solution Explorer tree
        Dim UIHSolutionExplorer As UIHierarchy
        UIHSolutionExplorer = DTE.Windows.Item(Constants.vsext_wk_SProjectWindow).Object()
        ' Check if there is any open solution
        If (UIHSolutionExplorer.UIHierarchyItems.Count = 0) Then
            ' MsgBox("Nothing to collapse. You must have an open solution.")
            Return
        End If
        ' Get the top node (the name of the solution)
        Dim UIHSolutionRootNode As UIHierarchyItem
        UIHSolutionRootNode = UIHSolutionExplorer.UIHierarchyItems.Item(1)
        UIHSolutionRootNode.DTE.SuppressUI = True
        ' Collapse each project node
        Dim UIHItem As UIHierarchyItem
        For Each UIHItem In UIHSolutionRootNode.UIHierarchyItems
            'UIHItem.UIHierarchyItems.Expanded = False
            If UIHItem.UIHierarchyItems.Expanded Then
                Collapse(UIHItem)
            End If
        Next
        ' Select the solution node, or else when you click 
        ' on the solution window
        ' scrollbar, it will synchronize the open document 
        ' with the tree and pop
        ' out the corresponding node which is probably not what you want.
        UIHSolutionRootNode.Select(vsUISelectionType.vsUISelectionTypeSelect)
        UIHSolutionRootNode.DTE.SuppressUI = False
    End Sub

    Private Sub Collapse(ByVal item As UIHierarchyItem)
        ' Recursively collapse
        For Each eitem As UIHierarchyItem In item.UIHierarchyItems
            If eitem.UIHierarchyItems.Expanded AndAlso eitem.UIHierarchyItems.Count > 0 Then
                Collapse(eitem)
            End If
        Next

        ' First try to collapse
        item.UIHierarchyItems.Expanded = False

        ' Check if it failed, if yes, then do it manually
        If item.UIHierarchyItems.Expanded = True Then
            item.Select(vsUISelectionType.vsUISelectionTypeSelect)
            DTE.ToolWindows.SolutionExplorer.DoDefaultAction()
        End If
    End Sub
End Module

Comments


4/10/2010 8:12:27 PM #

thaks for the share

yokser |



4/14/2010 7:20:17 AM #

You got a really useful blog I have been here reading for about an hour. I am a newbie and your success is very much an inspiration for me.if u need a good skin care just proceed to them.. i have taken care of my skin from them u can also have best skin care.

firming skin care |



4/14/2010 10:00:35 AM #

This is a really good read for me, Must admit that you are one of the best bloggers I ever saw.Thanks for posting this informative article.They have a great hand in Helping with writing your essay, coursework, assignment, Dissertation Writing etc..More than Ten Years Experience. Years of productive relations with clients.

Buy Essay |



4/15/2010 9:22:01 AM #

I’ve been reading a few posts and genuinely and enjoy your writing. I’m just starting up my own blog and only hope that I can write as well and give the reader so significantly insight.

make a website |



4/20/2010 10:44:07 AM #

The blog is in reality the great on this worthy subject. I match in together with your conclusions and looking forward to your coming updates. Just saying thanks will not just be enough, for the fantastic clarity inside your writing. I put a link to your blog at my site, hope you dont mind?

adjustable beds frame |



4/20/2010 2:45:26 PM #

I must say that this is a great post..Really i am impressed from this post....the person who create this post it was a great human. I put a link to your blog at my site, hope you dont mind?

Watch Hot Movies Online |



4/29/2010 10:22:40 AM #

I must say that this is a great post..Really i am impressed from this post....the person who create this post it was a great human. I put a link to your blog at my site, hope you dont mind?

Prudential West |



5/3/2010 8:42:40 AM #

Can I deduct a business mortage payment or only the interest and why?

Investment properties |



5/4/2010 7:15:18 AM #

Hello, I have browsed most of your posts. This post is probably where I got the most useful information for my research. Thanks for posting, maybe we can see more on this. Are you aware of any other websites on this subject

free stuff |



5/7/2010 4:21:51 PM #

This article gives the light in which we can observe the reality. this is very nice one and gives in depth information. thanks for this nice article Good post.....Valuable information for all.I will recommend my friends to read this for sure…

how much compensation for wiplash |



5/10/2010 10:25:05 AM #

Admiring the time and effort you put into your blog and detailed information you offer! I will bookmark your blog and have my children check up here often. Thumbs up!

debt solution |



5/13/2010 1:20:19 PM #

This article gives the light in which we can observe the reality. this is very nice one and gives indepth information. thanks for this nice

trust deeds |


Comments are closed
Disclaimer: The opinions expressed in this blog are own personal opinions and do not represent the companies view.
© 2000-2011 exDream GmbH & MobileBits GmbH. All rights reserved. Legal/Impressum

Poll

Which platform should Soulcraft be released on next?











Show Results Poll Archive

Recent Games

Soulcraft

Fireburst

Jobs @ exDream

Calendar

<<  April 2014  >>
MoTuWeThFrSaSu
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011