Esempio n. 1
0
        public GetOptions WithProjection(params string[] fields)
        {
            if (ProjectList == null)
            {
                ProjectList = new List <string>();
            }

            ProjectList.AddRange(fields);
            return(this);
        }
Esempio n. 2
0
        public async Task <Solution> AnalyzeSolution(string solutionFile, List <string> projectReferenceNamesToIgnore = null, List <string> projectNamesToIgnore = null)
        {
            var      fileInfo = new FileInfo(solutionFile);
            Solution solution = null;

            if (fileInfo.Exists)
            {
                Console.WriteLine($"Examining solution '{solutionFile}' for dependencies");
                solution = new Solution
                {
                    Name = fileInfo.Name,
                    Path = fileInfo.DirectoryName
                };

                var projects = await GetProjectPaths(solutionFile);

                var debugInfo = $"For solution {solutionFile}, the following projects are examined:{Environment.NewLine}";

                projectNamesToIgnore          = projectNamesToIgnore == null ? new List <string>() : projectNamesToIgnore;
                projectReferenceNamesToIgnore = projectReferenceNamesToIgnore == null ? new List <string>() : projectReferenceNamesToIgnore;

                if (projects.Any())
                {
                    var tasks = new List <Task <Project> >();

                    projects.ForEach(p =>
                    {
                        if (p.EndsWith("csproj") && !projectNamesToIgnore.Any(i => p.IndexOf(i) >= 0))
                        {
                            debugInfo += $"\t{p}{Environment.NewLine}";
                            tasks.Add(_projectAnalyzer.AnalyzeProject(p, projectReferenceNamesToIgnore));
                        }
                    });

                    if (tasks.Any())
                    {
                        Console.WriteLine(debugInfo);
                    }

                    var projectResults = await Task.WhenAll(tasks);

                    var projectList = new ProjectList();
                    projectList.AddRange(projectResults);

                    solution.Projects = projectList;
                }
            }
            else
            {
                Console.WriteLine($"Could not locate solution '{solutionFile}'");
            }

            return(solution);
        }
Esempio n. 3
0
 public GetOptions WithProjection(params string[] fields)
 {
     ProjectList.AddRange(fields);
     return(this);
 }