How can I get only projects from the solution?

大城市里の小女人 提交于 2019-12-04 22:35:24

问题


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?


回答1:


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();



回答2:


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?



来源:https://stackoverflow.com/questions/22802945/how-can-i-get-only-projects-from-the-solution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!