VS2010 DTE Addin: project inside solution folder is not "Project"
I have a small vs addin which looks for projects inside a solution and does a few stuff with it. I collect the projects like this:
Application.DTE.Solution.Projects.OfType<Project>();
However, as soon as I introduced a solution folder and placed a project inside it, suddenly that project was nowhere to be found. So, I've 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 the project is not there. So I've che开发者_如何学Gocked manually, calling item is Project
on a
- project directly inside the solution is TRUE
- solution folder directly inside the solution is TRUE (small wtf)
- project inside a solution folder (I've found it in
folder.ProjectItems
) is FALSE !!!!! (and of course explicit casting throws an error)
What the hell?
Without casting it to Project
, I cannot call FullName
, Properties()
and many other things on it, even if I cast to dynamic. Please help!
The answer is here : http://www.wwwlicious.com/2011/03/29/envdte-getting-all-projects-html/
Just few changes :
if (project.Kind == EnvDTE.Constants.vsProjectKindSolutionItems)
精彩评论