VS2010 DTE Addin: the project inside the solutions folder is not "Project"

I have a small vs addin that searches for projects inside a solution and does a few things with it. I collect projects as follows:

Application.DTE.Solution.Projects.OfType<Project>(); 

However, as soon as I presented the solutions folder and placed the project inside it, suddenly this project was not found anywhere. So I tried

  private IEnumerable<Project> getProjectsRecursive(IEnumerable<Project> iEnumerable) { foreach (var item in iEnumerable) { yield return item; foreach (var child in getProjectsRecursive(item.ProjectItems.OfType<Project>())) { yield return child; } } } public IEnumerable<Project> EveryProject { get { return getProjectsRecursive(Application.DTE.Solution.Projects.OfType<Project>()); } } 

still no project. So I checked manually by calling item is Project on

  • project directly inside the solution TRUE Solutions folder
  • directly inside the TRUE solution (small wtf)
  • inside the solutions folder (I found it in folder.ProjectItems ) FALSE !!!!! (and, of course, explicit casting causes an error)

What the heck? Without dropping it on Project , I cannot call FullName , Properties() and much more on it, even if I move on to dynamic. Please, help!

+6
source share
1 answer

The answer is here: http://www.wwwlicious.com/2011/03/29/envdte-getting-all-projects-html/

Just a few changes:

 if (project.Kind == EnvDTE.Constants.vsProjectKindSolutionItems) 
+8
source

Source: https://habr.com/ru/post/890921/


All Articles