示例#1
0
        public string CreateSolutionFilter(FileInfo solutionFileInfo, string[] projectsGlob, string relativeTo = null)
        {
            var solution  = _projectFactory.LoadSolution(solutionFileInfo.FullName);
            var filesGlob = GetProjectFilesGlob(projectsGlob);
            var projects  = solution.GetProjects(true).Where(p => filesGlob.IsMatch(p.FullPath));

            projects = GetProjectReferences(projects, true, true);

            var solutionFilterFile = new SolutionFilterFile
            {
                SolutionFilter = new SolutionFilter
                {
                    Path     = Path.GetRelativePath(relativeTo ?? FullPath, solution.FullPath),
                    Projects = projects.Select(p => Path.GetRelativePath(solution.DirectoryPath, p.FullPath)).ToArray()
                }
            };

            return(JsonConvert.SerializeObject(solutionFilterFile, Formatting.Indented));
        }