public ReadOnlyCollection<string> Parse(string solutionFile)
{
if (solutionFile == null)
{
throw new ArgumentNullException("solutionFile");
}
string solutionPath = Path.GetDirectoryName(solutionFile);
List<string> projectFiles = new List<string>();
using (StreamReader reader = new StreamReader(solutionFile, true))
{
while (!reader.EndOfStream)
{
//
// Find lines like the following:
// Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NArrange.Core", "NArrange.Core\NArrange.Core.csproj", "{CD74EA33-223D-4CD9-9028-AADD4E929613}"
//
string line = reader.ReadLine().TrimStart();
if (line.StartsWith("Project(", StringComparison.OrdinalIgnoreCase))
{
string[] projectData = line.Split(',');
string projectFile = projectData[1].Trim().Trim('"');
string projectPath = Path.Combine(solutionPath, projectFile);
if (!string.IsNullOrEmpty(Path.GetExtension(projectPath)))
{
projectFiles.Add(projectPath);
}
}
}
}
return projectFiles.AsReadOnly();
}