How can I get only projects from a solution?

I get a list of projects using the following:

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

See more details.

But he gives me all the elements in the solution, such as catalogs, projects, etc. I need only projects.

How can I get only projects from a solution?

+6
source share
2 answers

I tried and got the expected results. It may be another better solution, but it really works for me.

 var projects = CommonMethods.GetProjects(solution).Where(item => item.FullName != string.Empty).ToList(); 
+5
source

Sry I am just starting with programming, so it may be that my decisive way is really not the best, but I ran into the same problem recently.

To solve this problem, I analyzed all the solution elements in the list, and later I just checked if the relational elements path has the suffix ".csproj" or any other project that I need and wrote them in a new one. Maybe this can help you?

0
source

All Articles