views:

84

answers:

2

How do I take a Visual Studio Solution (.sln) as input and get a list of all the projects it contains?

+1  A: 

It's just a text file. Open it up in a text editor and see. You're looking for all the Project directives. Writing a simple parser to just extract the *.vcproj names shouldn't be difficult at all.

Warren Young
+2  A: 

This array will give you full solution details with project created with in solution..

public List<string> getAllProjectNames(string path)
    {
        string[] arr =  System.IO.File.ReadAllLines(path);
        List<string> projects = new List<string>();
        for (int i = 0; i < arr.Length; i++)
        {
            if (arr[i].StartsWith("Project"))
            {
                string [] temp = arr[i].Split(',');
                projects.Add(temp[1]);
            }
        }
        return projects;
    }

Call this metohd like..

List<string> Arr = getAllProjectNames(@"D:\Projects\PersonalRD\SearchingList\SearchingList.sln");

after that try to search all project names where the string item starts with project..

Jaswant Agarwal