public void FindAndLoadProjects2(DotnetWorkspace workspace) { foreach (var solution in workspace.Solutions) { var scanPath = solution.GlobalJson.FolderPath; var projectJsonMatches = new Matcher() .AddInclude("**/project.json") .Execute(new DirectoryInfoWrapper(new DirectoryInfo(scanPath))); foreach (var file in projectJsonMatches.Files) { var projectJsonPath = Path.Combine(scanPath, file.Path); Console.WriteLine($" Loading {projectJsonPath}"); var project = DotnetProject.Load(projectJsonPath); project.Solution = solution; solution.Projects.Add(project); } } }
public void FindAndLoadProjects1(DotnetWorkspace workspace) { foreach (var solution in workspace.Solutions) { if (!solution.GlobalJson.ProjectFolders.Any()) { Console.WriteLine($"NO 'projects' folders {solution.GlobalJson.FolderPath}"); continue; } foreach (var projectFolder in solution.GlobalJson.ProjectFolders) { var scanPath = Path.Combine(solution.GlobalJson.FolderPath, projectFolder.Path); if (!scanPath.StartsWith(solution.GlobalJson.FolderPath) || projectFolder.Path.StartsWith(".")) { Console.WriteLine($"OUTSIDE FOLDER {solution.GlobalJson.FolderPath}:{projectFolder.Path}"); continue; } Console.WriteLine($"Scanning {solution.GlobalJson.FolderPath}:{projectFolder.Path}"); var projectJsonMatches = new Matcher() .AddInclude("*/project.json") .Execute(new DirectoryInfoWrapper(new DirectoryInfo(scanPath))); foreach (var file in projectJsonMatches.Files) { var projectJsonPath = Path.Combine(scanPath, file.Path); Console.WriteLine($" Loading {projectJsonPath}"); var project = DotnetProject.Load(projectJsonPath); project.Solution = solution; solution.Projects.Add(project); } } } }