user185040
user185040

Reputation: 51

How to search a Visual Studio Solution for all the projects it contains?

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

Upvotes: 1

Views: 683

Answers (2)

Jaswant Agarwal
Jaswant Agarwal

Reputation: 4905

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 method 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...

Upvotes: 2

Warren Young
Warren Young

Reputation: 42333

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.

Upvotes: 1

Related Questions