private bool FindSolution(ProjectDescription description, out SolutionDescription solutionDescription) { var parentDirecotry = new FileInfo(description.FullName).Directory.Parent; while (parentDirecotry != null) { var solutions = parentDirecotry.GetFiles().Where(p => p.FullName.EndsWith(".sln")); if (solutions.Any()) { foreach (var item in solutions) { var prjlist = _solutionParser.Parser(item.FullName); if (prjlist.Any(p => $"{{{p.Guid.ToString().ToLower()}}}" == description.ProjectGuid.ToLower())) { solutionDescription = new SolutionDescription { FullName = item.FullName, Location = item.Directory, Name = item.Name }; return(true); } } } parentDirecotry = parentDirecotry.Parent; } solutionDescription = null; return(false); }
/// <summary> /// find project /// </summary> /// <param name="solutionFilePath"></param> /// <param name="project"></param> /// <param name="ownerProject"></param> /// <returns></returns> private bool ProjectFinder(string solutionFilePath, ProjectDescription project, out IList <ProjectDescription> ownerProjects) { var projectList = _solutionParser.Parser(solutionFilePath); ownerProjects = new List <ProjectDescription>(); if (projectList != null && projectList.Any()) { foreach (var proj in projectList) { var referProjects = MsToolkit.GetReferAssembly(proj.ProjectFile); if (referProjects.Where(p => p.ToLower().Contains(project.ProjectGuid.ToLower())).ToList().Count() != 0) { var ProjectParserFactory = ContainerManager.Resolve <IProjectParserServiceFactory>(); var projectParser = ProjectParserFactory.Create(AnalysisFileType.CSPROJ); var projectx = projectParser.Parser(proj.ProjectFile); if (!_projectFilter.IsValid(Path.GetFileName(proj.ProjectFile))) { continue; } if (projectx.ProjectType == VsProjectType.ClassLibrary || projectx.ProjectType == VsProjectType.Undefined) { continue; } projectx.Name = proj.Name; projectx.Location = new FileInfo(proj.ProjectFile).Directory; projectx.FullName = proj.ProjectFile; projectx.IsNeedCompile = false; ownerProjects.Add(projectx); } } return(ownerProjects.Count > 0); } return(false); }