Exemplo n.º 1
0
        private SolutionOptions CreateOptionsFromControls()
        {
            SolutionOptions options = new SolutionOptions
            {
                SolutionFolderPath    = Path.GetDirectoryName(this.textSolutionFile.Text),
                ProjectRootFolderPath = this.textProjectRoot.Text,
                IncludeFilter         = this.textIncludeFilter.Text,
                ExcludeFilter         = this.textExcludeFilter.Text,
                Recursive             = this.checkRecursive.Checked,
                IncludeReferences     = this.checkIncludeReferences.Checked,
                ProjectTypes          = ParseProjectTypesOption(this.textProjectTypes.Text),
                OverwriteReadOnlyFile = this.checkOverwriteReadonly.Checked,
                SolutionFileVersion   = this.radioVersion2012.Checked ?
                                        SolutionFileVersion.VisualStudio2012 : this.radioVersion2010.Checked ?
                                        SolutionFileVersion.VisualStudio2010 :
                                        SolutionFileVersion.VisualStudio2008,
                SolutionFolderLevels = (int)this.numericSolutionFolderLevels.Value,
                FolderNamingMode     = this.radioUseProjectNames.Checked ?
                                       SolutionFolderNamingMode.Project : this.radioUseAssemblyNames.Checked ?
                                       SolutionFolderNamingMode.Assembly :
                                       SolutionFolderNamingMode.MostQualified,
                CommonPrefixLevels = (int)this.numericCommonPrefixLevels.Value,
                CommonPrefixes     = this.textCommonPrefixes.Text,

                UpdateMode = GetUpdateMode()
            };

            return(options);
        }
Exemplo n.º 2
0
        static int InstallSolution(SolutionOptions opts)
        {
            RADSInteractor radsInteractor = new RADSInteractor(opts.CDNBaseURL);

            radsInteractor.InstallSolution(opts.OutputFolder, opts.Name, opts.Version, opts.Localization, opts.DeployMode);
            return(1);
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
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);
            }
        }
Exemplo n.º 5
0
        private void SaveSettings(SolutionOptions options, string settingsPath)
        {
            string settings = Serializer.ToXmlString(options);

            using (var writer = new StreamWriter(settingsPath))
            {
                writer.Write(settings);
            }
        }
Exemplo n.º 6
0
 private void UpdateSolutionCaps(bool enableCap, string cap)
 {
     if (enableCap == false)
     {
         SolutionOptions.Remove(cap);
     }
     else
     {
         SolutionOptions.Add(cap);
     }
 }
Exemplo n.º 7
0
        public static void GenSln(List <PrjInfo> thisLevel, int level, string slnDir = null)
        {
            if (IsNullOrEmpty(slnDir))
            {
                slnDir = BomBuildOption.SlnPath;
            }
            if (!Directory.Exists(slnDir))
            {
                Directory.CreateDirectory(slnDir);
            }

            var prjs = thisLevel.Where(item => !IsNullOrEmpty(item.PrjFilePath)).ToList();

            if (prjs.Count == 0)
            {
                return;
            }


            var generator = new SolutionGenerator(new ConsoleLogger());
            var firstPrj  = prjs.First();

            var slnFilePath = Path.Combine(slnDir,
                                           $"{firstPrj.BuildStage}BuildSln{level.ToString().PadLeft(3, '0')}");

            //创建一个空解决方案,否则第一个项目的相对路径会出错
            using (var fs = File.Create(slnFilePath))
            {
            }


            var slnOpt = new SolutionOptions
            {
                SolutionFolderPath    = slnFilePath,
                SolutionFileVersion   = SolutionFileVersion.VisualStudio2012,
                ProjectRootFolderPath = firstPrj.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);
            }
            //添加build所需的Section

            AdjustBuildSln(slnOpt.SolutionFolderPath, prjs);
        }
Exemplo n.º 8
0
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            this.solutionOptions = new SolutionOptions();
            this.AddOptionKey(Constants.SolutionOptionKey);

            this.Options   = (IOptions)this.GetDialogPage(typeof(BindingOptions));
            this.Telemetry = new Telemetry(this.Options, this.solutionOptions);
            this.Telemetry.TrackEvent(Constants.EventInitializePackage);

            await this.InitMenuCommandsAsync();
        }
Exemplo n.º 9
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);
            }
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            var basePath = "../../../../A2v10.Application/App_Application";
            var s        = Solution.LoadFromFile($"{basePath}/solution.json");
            var styles   = Styles.LoadFromFile($"{basePath}/styles.json");

            var opts = new SolutionOptions();
            var xaml = new XamlBuilder(styles);
            var sql  = new SqlBuilder(opts);

            var b = new AppBuilder(s, xaml, sql);

            b.Build(basePath + "/sample");
            //Directory.CreateDirectory("../../../../Application/sample");
            b.BuildSql($"{basePath}/sample_full.sql");
        }
Exemplo n.º 11
0
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            this.options = new SolutionOptions();
            this.AddOptionKey(Constants.SolutionOptionKey);

            this.telemetry = new Telemetry(this.options);
            this.telemetry.TrackEvent(Constants.EventInitializePackage);

            // Add a command handler for showing the tool window
            CommandID             menuCommandID  = new CommandID(Constants.GuidCommandSet, Constants.BindingToolWindowCommandId);
            MenuCommand           menuItem       = new MenuCommand((s, a) => this.ShowBindingPane(), menuCommandID);
            OleMenuCommandService commandService = await this.GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService;

            commandService?.AddCommand(menuItem);
        }
Exemplo n.º 12
0
        private void AssignOptionsToControls(SolutionOptions options)
        {
            this.textProjectRoot.Text               = options.ProjectRootFolderPath;
            this.textIncludeFilter.Text             = options.IncludeFilter;
            this.textExcludeFilter.Text             = options.ExcludeFilter;
            this.checkRecursive.Checked             = options.Recursive;
            this.checkIncludeReferences.Checked     = options.IncludeReferences;
            this.textProjectTypes.Text              = FormatProjectTypesOption(options.ProjectTypes);
            this.checkOverwriteReadonly.Checked     = options.OverwriteReadOnlyFile;
            this.radioVersion2008.Checked           = options.SolutionFileVersion == SolutionFileVersion.VisualStudio2008;
            this.radioVersion2010.Checked           = options.SolutionFileVersion == SolutionFileVersion.VisualStudio2010;
            this.radioVersion2012.Checked           = options.SolutionFileVersion == SolutionFileVersion.VisualStudio2012;
            this.numericSolutionFolderLevels.Value  = options.SolutionFolderLevels;
            this.radioUseProjectNames.Checked       = options.FolderNamingMode == SolutionFolderNamingMode.Project;
            this.radioUseAssemblyNames.Checked      = options.FolderNamingMode == SolutionFolderNamingMode.Assembly;
            this.radioUseMostQualifiedNames.Checked = options.FolderNamingMode == SolutionFolderNamingMode.MostQualified;
            this.numericCommonPrefixLevels.Value    = options.CommonPrefixLevels;
            this.radioCommonPrefixes.Checked        = !string.IsNullOrEmpty(options.CommonPrefixes);
            this.textCommonPrefixes.Text            = options.CommonPrefixes;

            SelectProjectTypes();
            SetUpdateMode(options.UpdateMode);
        }
        protected override void Execute()
        {
            SolutionOptions options = new SolutionOptions();

            Solution.GetProperty((int)__VSPROPID.VSPROPID_SolutionDirectory, out object solutionDirectoryRaw);
            Solution.GetProperty((int)__VSPROPID.VSPROPID_SolutionBaseName, out object solutionNameRaw);
            string solutionName      = solutionNameRaw.ToString();
            string solutionDirectory = solutionDirectoryRaw.ToString();

            options.SolutionName        = solutionName;
            options.SolutionDirectory   = solutionDirectory;
            options.RepositoryDirectory = new DirectoryInfo(solutionDirectory).Parent.FullName;

            IEnumerable <Project> projects = DTE.Solution.GetAllProjects();

            using (DialogScope progress2 = new DialogScope())
            {
                progress2.Update("Synchronizing project file properties with solution. Please wait...");


                foreach (Project project in projects)
                {
                    progress2.Update(
                        "Synchronizing project file properties with solution. Please wait...",
                        $"Processing Project '{project.Name}'"
                        );

                    // ===========================
                    //            Flow
                    // ===========================
                    //
                    // 1) Snapshot project file full path.
                    // 2) Open Project File with filePath and snapshot its ProjectRootElement.
                    // 3) Retrieve Project GUID of the project snapshotted in step 1
                    // 4) Unload project as if user manually unloaded it, and then close it
                    //
                    // 5) Walk property elements, stop at chosen property Name
                    // 5.1) Get the parent of the property element (should be a ProjectPropertyGroupElement)
                    // 5.2) Remove the property element, which will be an immediate child of the parent you just got in 5.1
                    // 6) Save the ProjectRootElement
                    // 7) Reload the project. This is where the GUID from step 3 comes in handy.
                    // 8) For good measure, save the project via the hierarchy.
                    // 9) You are done, Son!
                    //
                    //

                    string projectFilePath = project.FullName;



                    Solution.GetProjectOfUniqueName(project.UniqueName, out IVsHierarchy ppHierarchy);
                    Solution.GetGuidOfProject(ppHierarchy, out Guid projectGuid);
                    Solution4.UnloadProject(ref projectGuid, (uint)_VSProjectUnloadStatus.UNLOADSTATUS_UnloadedByUser);
                    Solution.CloseSolutionElement((uint)__VSSLNCLOSEOPTIONS.SLNCLOSEOPT_UnloadProject, ppHierarchy, VSConstants.VSITEMID_NIL);



                    ProjectRootElement root = ProjectLoader.LoadProject(projectFilePath).Xml;

                    foreach (ProjectPropertyElement propertyElement in root.Properties)
                    {
                        // Check for the most common property names for
                        // output paths. The names checked below are
                        // non-exhaustive. Technically, OutputPath should
                        // be sufficient; however, OutDir is used as
                        // well, but not very often.
                        if (propertyElement.Name.Equals("OutputPath") ||
                            propertyElement.Name.Equals("OutDir"))
                        {
                            propertyElement.Parent.RemoveChild(propertyElement);
                            root.Save(projectFilePath);
                        }
                    }

                    // This has to come after the properties are removed. Otherwise you get some error
                    // saing The SDK '' could not be found.
                    ProjectXmlService.SetExplicitSdkImportsIfNecessaryAsync(projectFilePath);

                    Solution4.ReloadProject(ref projectGuid);
                    Solution4.EnsureProjectIsLoaded(ref projectGuid, 0);
                    Solution.SaveSolutionElement((uint)__VSSLNSAVEOPTIONS.SLNSAVEOPT_ForceSave, ppHierarchy, VSConstants.VSITEMID_NIL);
                }
            }

            DirectoryBuildPropsWriter.WriteDirectoryBuildProps(options);

            Project solutionItems = DTE.Solution.GetOrCreateSolutionFolder("Solution Items");

            solutionItems.ProjectItems.AddFromFile(options.DirectoryBuildPropsPath);

            DTE.Collapse();
        }
 protected bool Equals(SolutionOptions other)
 {
     return(string.Equals(Name, other.Name) && string.Equals(Nuspecs, other.Nuspecs) &&
            string.Equals(SrcFolder, other.SrcFolder) && string.Equals(BuildCmd, other.BuildCmd) &&
            string.Equals(FastBuildCommand, other.FastBuildCommand) && Constraints.Equals(other.Constraints));
 }
 public EglibProjectPatcher(SolutionOptions solutionOptions)
     : base(solutionOptions, solutionOptions?.EglibProject)
 {
 }
Exemplo n.º 16
0
 public LibgcProjectPatcher(SolutionOptions solutionOptions)
     : base(solutionOptions, solutionOptions?.LibgcProject)
 {
 }
 public GenmdescProjectPatcher(SolutionOptions solutionOptions)
     : base(solutionOptions, solutionOptions?.GenmdescProject)
 {
 }
Exemplo n.º 18
0
 protected ProjectPatcherV40(SolutionOptions solutionOptions, ProjectInfo project)
     : base(solutionOptions, project, ConstantsV40.OldProjectToolsVersion, ConstantsV40.NewProjectToolsVersion)
 {
 }