Skip to content

Instantly share code, notes, and snippets.

@kad1r
Created April 11, 2013 23:30
Show Gist options
  • Save kad1r/5368066 to your computer and use it in GitHub Desktop.
Save kad1r/5368066 to your computer and use it in GitHub Desktop.
This code gives you the list of projects which are in the open solution in visual studio.
string slnPath = Directory.GetParent(Assembly.GetExecutingAssembly().Location).Parent.Parent.Parent.FullName;
List<string> projects = new List<string>();
foreach (string f in Directory.GetFiles(slnPath))
{
if (f.Contains(".sln"))
{
string[] arr = System.IO.File.ReadAllLines(f);
for (int i = 0; i < arr.Length; i++)
{
if (arr[i].StartsWith("Project"))
{
string[] temp = arr[i].Split(',');
projects.Add(temp[1]);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment