public string CheckSolutionProjectGuids( string solutionPath, string allowedProjectGuid, string checkProjectFilesExtensions) { var checkLog = new StringBuilder(); foreach (var solutionProject in solutionParser.ExtractSolutionProjects(solutionPath, projectFileExtension: "")) { if (!solutionProject.IsFolder && solutionProject.ProjectGuid != allowedProjectGuid && solutionProject.ProjectPath.Contains(checkProjectFilesExtensions)) { checkLog.AppendLine( $"Solution project {solutionProject.ProjectPath} has the project GUID {solutionProject.ProjectGuid}. It should be {allowedProjectGuid}!"); } } var complaints = checkLog.ToString(); if (!string.IsNullOrEmpty(complaints)) { complaints = $"Complaints for the solution: {solutionPath}" + Environment.NewLine + complaints; } return(complaints); }
public IEnumerable <string> CheckProjectReferencesExistenceInSolution(string solutionPath, string projectFileExtension) { if (File.GetAttributes(solutionPath).HasFlag(FileAttributes.Directory)) { throw new ArgumentException($"You passed a folder path {solutionPath} to the {nameof(solutionPath)} parameter. Please pass the solution file path."); } var messages = new List <string>(); var absoluteProjectPaths = new HashSet <string>(_solutionParser.ExtractSolutionProjects(solutionPath, projectFileExtension).Select(sp => Path.GetFullPath(sp.ProjectPath))); foreach (var projectPath in absoluteProjectPaths) { var projectDir = Path.GetDirectoryName(projectPath); var absoluteReferencePaths = _referencesExtractor.GetProjectReferencePaths(projectPath).Select(p => Path.GetFullPath(Path.Combine(projectDir, p))); foreach (var referencePath in absoluteReferencePaths) { if (!absoluteProjectPaths.Contains(referencePath)) { var shouldBeTowards = absoluteProjectPaths.SingleOrDefault(pp => pp.EndsWith(Path.GetFileName(referencePath))); var message = $"Project {Path.GetFileName(projectPath)} has a broken reference to {referencePath}."; if (string.IsNullOrEmpty(shouldBeTowards)) { message += $" This reference is completely missing from the solution {Path.GetFileName(solutionPath)}"; } else { message += $" The reference should be towards {shouldBeTowards}"; } messages.Add(message); } } } return(messages); }