public Solution Parse(string path, bool skipTestProjects = true) { path = Path.GetFullPath(path); var basePath = Path.GetDirectoryName(Path.GetFullPath(path)); var solutionData = File.ReadAllText(path); var projectPathMatches = SolutionProjectRe.Matches(solutionData); var projects = new HashSet <Project>(); foreach (Match?projectPathMatch in projectPathMatches) { Debug.Assert(projectPathMatch != null); var projectRelativePath = projectPathMatch.Groups[1].Value.Replace('\\', Path.DirectorySeparatorChar); var projectPath = Path.Join(basePath, projectRelativePath); if (!File.Exists(projectPath)) { throw new FileNotFoundException("The project file does not exist.", projectPath); } if (skipTestProjects && TestProjectRe.IsMatch(projectPath)) { continue; } projects.Add(_projectParser.Parse(projectPath, true)); } return(new Solution(path, ImmutableHashSet.Create(projects.ToArray()))); }
/// <summary> /// Gets all source files associated with a project. /// </summary> /// <param name="fileName">Project file name.</param> /// <returns>A collection of source files associated with the project.</returns> private ReadOnlyCollection <string> GetProjectSourceFiles(string fileName) { List <string> sourceFiles = new List <string>(); ProjectHandler handler = GetProjectHandler(fileName); if (handler != null) { bool isRecognizedProject = IsRecognizedFile(fileName, handler.Configuration.ProjectExtensions); if (isRecognizedProject) { IProjectParser projectParser = handler.ProjectParser; ReadOnlyCollection <string> fileNames = projectParser.Parse(fileName); foreach (string sourceFile in fileNames) { if (IsRecognizedSourceFile(sourceFile)) { sourceFiles.Add(sourceFile); } } } } return(sourceFiles.AsReadOnly()); }
private ProjectDocument parseDocument(Project record) { try { return(_parser.Parse(record.Key, record.Value)); } catch (Exception exception) { var messageString = string.Format("Failed parsing project {0}. Project will not be built. ({1})", record.Key, exception.Message); Debug.WriteInfo(messageString); } return(null); }
public IReadOnlyList <Project> GetProjects() { var solutionFile = SolutionFile.Parse(_solutionFilePath); var projectsInSolution = solutionFile.ProjectsInOrder; var projects = new List <Project>(); foreach (var projectInSolution in projectsInSolution) { var project = _projectParser.Parse(projectInSolution.ProjectGuid, projectInSolution.ProjectName, projectInSolution.AbsolutePath); projects.Add(project); } return(projects); }