How can I get only projects from the solution?
Asked Answered
C

2

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?

Continuum answered 2/4, 2014 at 6:14 Comment(0)
C
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();
Continuum answered 2/4, 2014 at 6:14 Comment(0)
R
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?

Rhynd answered 2/4, 2014 at 6:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.