public StackReport Run() { var stackReport = new StackReport(); var solutionFiles = Directory.EnumerateFiles(_workingDirectory, "*.sln", SearchOption.AllDirectories).ToList(); solutionFiles.ForEach(s=> { var solution = new Solution { Name = Path.GetFileNameWithoutExtension(s), Location = s, }; stackReport.Results.Add(solution); var solutionFileContent = File.ReadAllText(s); var projRegex = new Regex("Project\\(\"\\{[\\w-]*\\}\"\\) = \"([\\w _]*.*)\", \"(.*\\.(cs)proj)\"", RegexOptions.Compiled); var matches = projRegex.Matches(solutionFileContent).Cast<Match>(); var projectFiles = matches.Select(x => x.Groups[2].Value).ToList(); projectFiles.ForEach(p=> { var project = new Project { Name = Path.GetFileNameWithoutExtension(p), Location = p }; solution.Projects.Add(project); string projectFile; if (!Path.IsPathRooted(p)) { projectFile = Path.Combine(Path.GetDirectoryName(s), p); } else { projectFile = Path.GetFullPath(p); } var projectDependencies = ExtractReferencedAssemblies(projectFile); project.Dependencies.AddRange(projectDependencies); }); }); return stackReport; }
public StackReport Run() { var stackReport = new StackReport(); var solutionFiles = Directory.EnumerateFiles(_workingDirectory, "*.sln", SearchOption.AllDirectories).ToList(); //skip all files within the skip list var solutionFilesStage1 = solutionFiles.Where(f => !_skipList.Exists(f.Contains)) .ToList(); //tracks all with latest versions from 2013 - 2015 solutionFilesStage1.ForEach(f => { var versionMap = TrackWithVisualStudioVersion(f); if(null != versionMap) { var solution = new Solution { Name = Path.GetFileNameWithoutExtension(f), Location = f }; solution.Dependencies.Add(new SolutionDependency { Name = Name, Version = versionMap.ProductVersion }); stackReport.Results.Add(solution); } }); //tracks all that were skipped in stage 1 from 2003 - 2012 var solutionFilesStage2 = solutionFilesStage1.Where(f => !stackReport.Results.Exists(r => r.Location == f)).ToList(); solutionFilesStage2.ForEach(f=> { var versionMap = TrackWithSolutionFormat(f); if (null != versionMap) { var solution = new Solution { Name = Path.GetFileNameWithoutExtension(f), Location = f }; solution.Dependencies.Add(new SolutionDependency { Name = Name, Version = versionMap.ProductVersion }); stackReport.Results.Add(solution); } }); //record all skipped files and save as error var skippedFilesStage2 = solutionFilesStage1.Where(f => !stackReport.Results.Exists(r => r.Location == f)).ToList(); stackReport.Errors = skippedFilesStage2; return stackReport; }