コード例 #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);
            }
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: zlphoenix/LearnCSharp
        private void buttonSolutionFile_Click(object sender, EventArgs e)
        {
            SaveFileDialog dialog = new SaveFileDialog();
            dialog.Filter = "Solution files (*.sln)|*.sln";
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                this.textSolutionFile.Text = dialog.FileName;

                if (File.Exists(this.textSolutionFile.Text))
                {
                    SolutionReader reader = new SolutionReader();
                    var solution = reader.Read(this.textSolutionFile.Text);
                    if (solution.FileVersion == SolutionFileVersion.VisualStudio2008)
                    {
                        this.radioVersion2008.Checked = true;
                    }
                    else if (solution.FileVersion == SolutionFileVersion.VisualStudio2010)
                    {
                        this.radioVersion2010.Checked = true;
                    }
                    else if (solution.FileVersion == SolutionFileVersion.VisualStudio2012)
                    {
                        this.radioVersion2012.Checked = true;
                    }

                    string settingsPath = Path.ChangeExtension(this.textSolutionFile.Text, SolutionOptions.FileExtension);
                    if (File.Exists(settingsPath))
                    {
                        var options = LoadSettings(settingsPath);
                        AssignOptionsToControls(options);
                        this.checkSaveSettings.Checked = true;
                    }
                }
            }

            ValidateControls();
        }