GenerateSolution() public method

public GenerateSolution ( string solutionFile, SolutionOptions options, bool testOnly = false ) : Solution
solutionFile string
options SolutionOptions
testOnly bool
return SolutionMaker.Core.Model.Solution
Ejemplo n.º 1
0
        private static void GenSln(List<PrjInfo> thisLevel, int level)
        {
            var prjs = thisLevel.Where(item => !string.IsNullOrEmpty(item.PrjFilePath)).ToList();
            if (prjs.Count == 0) return;
            var generator = new SolutionGenerator(new ConsoleLogger());
            var slnOpt = new SolutionOptions();
            slnOpt.SolutionFolderPath = SlnPath + "buildSln" + level.ToString().PadLeft(3, '0') + ".sln";
            slnOpt.SolutionFileVersion = SolutionFileVersion.VisualStudio2012;
            slnOpt.ProjectRootFolderPath = prjs.FirstOrDefault().PrjFilePath;
            generator.GenerateSolution(slnOpt.SolutionFolderPath, slnOpt);

            prjs.RemoveAt(0);

            foreach (var prj in prjs)
            {
                slnOpt.UpdateMode = SolutionUpdateMode.Add;
                slnOpt.ProjectRootFolderPath = prj.PrjFilePath;
                generator.GenerateSolution(slnOpt.SolutionFolderPath, slnOpt);

            }




        }
Ejemplo n.º 2
0
        private void buttonExecute_Click(object sender, EventArgs e)
        {
            try
            {
                string message;

                if (File.Exists(this.textSolutionFile.Text))
                {
                    var fileAttributes = File.GetAttributes(this.textSolutionFile.Text);
                    if ((fileAttributes & FileAttributes.ReadOnly) != 0)
                    {
                        message = "The solution file is read only\r\nDo you want to overwrite it?";
                        if (MessageBox.Show(message, "Confirm Overwrite", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            File.SetAttributes(this.textSolutionFile.Text, fileAttributes ^ FileAttributes.ReadOnly);
                        }
                        else
                        {
                            return;
                        }
                    }
                }

                SolutionOptions options = CreateOptionsFromControls();
                SolutionGenerator generator = new SolutionGenerator(new StatusLogger(this.labelStatus));
                generator.GenerateSolution(this.textSolutionFile.Text, options);
                this.labelStatus.Text = string.Empty;

                if (generator.NumberOfProjectsFound > 0)
                {
                    message = string.Format("Solution file is generated\r\n\r\n{0} projects found\r\n{1} projects skipped\r\n{2} projects added\r\n{3} projects removed", 
                        generator.NumberOfProjectsFound, generator.NumberOfProjectsSkipped, generator.NumberOfProjectsAdded, generator.NumberOfProjectsRemoved);
                }
                else
                {
                    message = string.Format("No project files found in the specified location\r\nSolution file is not generated");
                }

                if (this.checkSaveSettings.Checked)
                {
                    SaveSettings(options, Path.ChangeExtension(this.textSolutionFile.Text, SolutionOptions.FileExtension));
                }

                MessageBox.Show(message, "Execution Summary", MessageBoxButtons.OK);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 3
0
        private static void GenerateSolutionFile(CommandLineOptions options)
        {
            if (!Directory.Exists(options.ProjectRootFolderPath))
            {
                throw new SolutionFileGenerationException("Invalid directory: " + options.ProjectRootFolderPath);
            }
            else if (File.Exists(options.SolutionFile) && ((File.GetAttributes(options.SolutionFile) & FileAttributes.ReadOnly) != 0) && !options.OverwriteReadOnlyFile)
            {
                throw new SolutionFileGenerationException("Solution file is read-only. Use /r option to overwrite read-only solution file.");
            }
            else
            {
                if (File.Exists(options.SolutionFile))
                {
                    var fileAttributes = File.GetAttributes(options.SolutionFile);
                    if ((fileAttributes & FileAttributes.ReadOnly) != 0 && options.OverwriteReadOnlyFile)
                    {
                        File.SetAttributes(options.SolutionFile, fileAttributes ^ FileAttributes.ReadOnly);
                    }
                }

                SolutionGenerator generator = new SolutionGenerator(new ConsoleLogger());
                generator.GenerateSolution(options.SolutionFile, options);

                string message;
                if (generator.NumberOfProjectsFound > 0)
                {
                    message = string.Format("Solution file is generated\r\n{0} projects found\r\n{1} projects skipped\r\n{2} projects added\r\n{3} projects removed",
                        generator.NumberOfProjectsFound, generator.NumberOfProjectsSkipped, generator.NumberOfProjectsAdded, generator.NumberOfProjectsRemoved);
                }
                else
                {
                    message = string.Format("No project files found in the specified location\r\nSolution file is not generated");
                }
                Console.WriteLine();
                Console.WriteLine(message);
            }
        }
Ejemplo n.º 4
0
        private void buttonPreview_Click(object sender, EventArgs e)
        {
            try
            {
                string message;

                SolutionOptions options = CreateOptionsFromControls();
                SolutionGenerator generator = new SolutionGenerator(new StatusLogger(this.labelStatus));
                var solution = generator.GenerateSolution(this.textSolutionFile.Text, options, true);
                this.labelStatus.Text = string.Empty;

                if (generator.NumberOfProjectsFound == 0)
                {
                    message = string.Format("No project files found in the specified location\r\nSolution file is not generated");
                    MessageBox.Show(message, "Execution Summary", MessageBoxButtons.OK);
                }
                else
                {
                    var previewForm = new PreviewForm();
                    previewForm.Solution = solution;
                    previewForm.SolutionFile = this.textSolutionFile.Text;
                    previewForm.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }