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 checked manually, calling item is Project
on a
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With