How many times have you been collapsing manually all the projects in your solution ranting about the fact there's no option to do that automagically? Loadza times is the answer - unless you only work on small projects (which is not a crime btw).
Anyway - after swearing at the screen a number of times I decided it was about time to do something about it and I googled it.
I found loads of awesome VS Macros to do what I was looking for but I hadn't a clue about how to create a VS Macro so I thought I'd share the whole thing.
First thing you need to go to Visual Studio Tools --> Macros --> Macro Explorer. Once you got that right click on MyMacros and create a new module (I called it CollapseAll).
Now edit the new module (double-click on it) erase whatever is in there and paste this stuff into it (if you want you can even try to understand what it does - but it's optional):
'Awesome Macros ripped-off
Public Module CollapseAll
Public Sub CollapseTopLevel()
Dim solutionWindow As EnvDTE.Window = DTE.ActiveWindow
solutionWindow.Visible = False
Dim solution As UIHierarchyItem = GetSolution()
CollapseHierarchy(solution.UIHierarchyItems, True, True)
solutionWindow.Visible = True
Private Sub CollapseHierarchy(ByRef items As UIHierarchyItems, ByVal IsRoot As Boolean, ByVal OnlyCollapseRootLevel As Boolean)
For i As Int32 = 1 To items.Count
If IsRoot Then DTE.StatusBar.Progress(True, "Collapsing", i, items.Count)
If (items.Item(i).UIHierarchyItems.Count > 0 And Not OnlyCollapseRootLevel) Then
DTE.StatusBar.Text = "Collapsing " & items.Item(i).Name
CollapseHierarchy(items.Item(i).UIHierarchyItems, False, False)
items.Item(i).UIHierarchyItems.Expanded = False
Private Function GetSolution() As UIHierarchyItem
Dim win As Window = DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer)
Dim uih As UIHierarchy = win.Object
GetSolution = uih.UIHierarchyItems.Item(1)
Now, the hard work is done - You'll see your CollapseTopLevel as a child of the CollapseAll module in you Macro Explorer and you can run it double clicking on it but we all know that sucks so the cool thing to do now is to assign an hotkey chord/combination to our kick-ass macro.
To do this you need to go to Tools-->Options-->Environment-->Keyboard. Pick your macro from the listBox with all the default VS stuff (remember it will be there like MyMacros.CollapseAll.CollapseTopLevel) and then assign a hotkey combination or chord to it (I used CTRL+K, CTRL+Y since it's not used by VS) and save.
P.S. I'd really like to thank Dan, who wrote the snippets I brutally ripped-off. The original article is awesome and there's plenty of nitty-gritty cut and paste potential there for developers in need.