Beispiel #1
0
        /// <summary>
        /// Locates the solution(s) where the specified project is (search up the tree up to the repository path)
        /// </summary>
        public static IList <VsSolution> FindContainingSolutions(string repositoryPath, string targetPath, IFileFinder fileFinder)
        {
            string solutionsPath = PathUtility.CleanPath(targetPath);

            repositoryPath = PathUtility.CleanPath(repositoryPath);

            while (solutionsPath != null && solutionsPath.Contains(repositoryPath))
            {
                var solutionsFound = from solution in GetSolutions(solutionsPath, fileFinder, SearchOption.TopDirectoryOnly)
                                     where ExistsInSolution(solution, targetPath)
                                     select solution;

                if (solutionsFound.Any())
                {
                    return(solutionsFound.ToList());
                }

                if (PathUtility.PathsEquals(solutionsPath, repositoryPath))
                {
                    break;
                }

                var parent = Directory.GetParent(solutionsPath);
                solutionsPath = parent != null?parent.ToString() : null;
            }

            return(new List <VsSolution>());
        }
Beispiel #2
0
 private static bool ExistsInSolution(VsSolution solution, string targetPath)
 {
     return((from p in solution.Projects
             where PathUtility.PathsEquals(p.AbsolutePath, targetPath)
             select p).Any());
 }