Пример #1
0
        public Solution GenerateSolution(string solutionFile, SolutionOptions options, bool testOnly = false)
        {
            this.NumberOfProjectsFound = 0;
            this.NumberOfProjectsSkipped = 0;
            this.NumberOfProjectsAdded = 0;
            this.NumberOfProjectsRemoved = 0;

            this._options = options;
            var rootDir = new DirectoryInfo(this._options.ProjectRootFolderPath);
            var includeFilter = new string[] { };
            if (!string.IsNullOrEmpty(this._options.IncludeFilter))
            {
                includeFilter = this._options.IncludeFilter.Split(';');
            }
            var excludeFilter = new string[] { };
            if (!string.IsNullOrEmpty(this._options.ExcludeFilter))
            {
                excludeFilter = this._options.ExcludeFilter.Split(';');
            }

            Solution oldSolution = null;
            if (File.Exists(solutionFile) && options.UpdateMode != SolutionUpdateMode.Replace)
            {
                var solutionReader = new SolutionReader();
                oldSolution = solutionReader.Read(solutionFile);
            }

            var projects = new List<SolutionProject>();
            ScanProjectDirectory(rootDir, projects, options.SolutionFileVersion, includeFilter, excludeFilter, this._options.Recursive);
            if (this._options.IncludeReferences)
            {
                ScanProjectReferences(projects, options.SolutionFileVersion, includeFilter, excludeFilter);
            }

            if (projects.Count > 0)
            {
                // Sort project files
                projects = (from p in projects orderby p.Name select p).ToList();

                var merger = new SolutionBuilder(options, _logger);
                var newSolution = merger.Build(oldSolution, projects);
                this.NumberOfProjectsAdded = merger.NumberOfProjectsAdded;
                this.NumberOfProjectsRemoved = merger.NumberOfProjectsRemoved;

                if (!testOnly)
                {
                    var solutionWriter = new SolutionWriter();
                    solutionWriter.Write(solutionFile, newSolution);
                }

                return newSolution;
            }
            else
            {
                return oldSolution;
            }
        }
Пример #2
0
        public Solution GenerateSolution(string solutionFile, SolutionOptions options, bool testOnly = false)
        {
            this.NumberOfProjectsFound   = 0;
            this.NumberOfProjectsSkipped = 0;
            this.NumberOfProjectsAdded   = 0;
            this.NumberOfProjectsRemoved = 0;

            this._options = options;
            var rootDir       = new DirectoryInfo(this._options.ProjectRootFolderPath);
            var includeFilter = new string[] { };

            if (!string.IsNullOrEmpty(this._options.IncludeFilter))
            {
                includeFilter = this._options.IncludeFilter.Split(';');
            }
            var excludeFilter = new string[] { };

            if (!string.IsNullOrEmpty(this._options.ExcludeFilter))
            {
                excludeFilter = this._options.ExcludeFilter.Split(';');
            }

            Solution oldSolution = null;

            if (File.Exists(solutionFile) && options.UpdateMode != SolutionUpdateMode.Replace)
            {
                var solutionReader = new SolutionReader();
                oldSolution = solutionReader.Read(solutionFile);
            }

            var projects = new List <SolutionProject>();

            ScanProjectDirectory(rootDir, projects, options.SolutionFileVersion, includeFilter, excludeFilter, this._options.Recursive);
            if (this._options.IncludeReferences)
            {
                ScanProjectReferences(projects, options.SolutionFileVersion, includeFilter, excludeFilter);
            }

            if (projects.Count > 0)
            {
                // Sort project files
                projects = (from p in projects orderby p.Name select p).ToList();

                var merger      = new SolutionBuilder(options, _logger);
                var newSolution = merger.Build(oldSolution, projects);
                this.NumberOfProjectsAdded   = merger.NumberOfProjectsAdded;
                this.NumberOfProjectsRemoved = merger.NumberOfProjectsRemoved;

                if (!testOnly)
                {
                    var solutionWriter = new SolutionWriter();
                    solutionWriter.Write(solutionFile, newSolution);
                }

                return(newSolution);
            }
            else
            {
                return(oldSolution);
            }
        }