0

I'm trying to create a little Visual Studio Extension, to do some batch project load and unloading. To do this, I have to select multiple projects at once and then call the Project.ReloadProject or Project.UnloadProject command. If I load or unload project after project, it's far too slow.

Here's my sample:

foreach (UIHierarchyItem item in solution.UIHierarchyItems)
{
    if (!filter.Projects.Contains(item.Name, StringComparer.CurrentCultureIgnoreCase))
        item.Select(vsUISelectionType.vsUISelectionTypeSelect);
}

dte.ExecuteCommand("Project.UnloadProject", "");

The problem is, that I don't know, how to select multiple projects at once. When I'm doing the same task manually, I just hold the ctrl button and click at the projects.

roli09
  • 817
  • 1
  • 8
  • 20

1 Answers1

2

To select multiple projects, for the first project call:

item.Select(vsUISelectionType.vsUISelectionTypeSelect);

for subsequent projects call:

   if (!item.IsSelected)
       item.Select(vsUISelectionType.vsUISelectionTypeToggle);
Sergey Vlasov
  • 26,641
  • 3
  • 64
  • 66
  • Thank you very much! Didn't consider that, because in the documentation it says after you select a node using the toggle value it is the ONLY selected node. – roli09 Dec 08 '18 at 22:01