6

I get a list of projects using following:

var solution = (IVsSolution)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(IVsSolution));

Refer following link for more details.

But it gives me each and every item in the solution like Directories, projects, etc. I require only projects.

How can I get only projects from the solution?

Community
  • 1
  • 1
Palak.Maheria
  • 1,497
  • 2
  • 15
  • 32

2 Answers2

5

I tried and got the expected results. There may be other better solution but this actually works for me.

var projects = CommonMethods.GetProjects(solution).Where(item => item.FullName != string.Empty).ToList();
Raptor
  • 53,206
  • 45
  • 230
  • 366
Palak.Maheria
  • 1,497
  • 2
  • 15
  • 32
0

Sry I'm just begining with programming so it could be that my solving way is really not the best but i faced the same problem short time ago.

To solve this problem I parsed all items of the solution in a list and later i just checked if the relativ path of the items has the suffix '.csproj' or any other kind of project i need and wrote them into a new list maybe this could help you to?

TreeRex
  • 1
  • 2