Пример #1
0
 /// <summary>
 /// Executes an MSBuild target.
 /// </summary>
 /// <param name="target">Name of the MSBuild target to execute.</param>
 /// <returns>Result from executing the target (success/failure).</returns>
 protected override Microsoft.VisualStudio.Project.BuildResult InvokeMsBuild(string target)
 {
     XBuildMacroCollection.DefineSolutionProperties(this);
     XBuildMacroCollection.DefineProjectReferenceConfigurations(this);
     ThreadHelper.ThrowIfNotOnUIThread();
     return(base.InvokeMsBuild(target));
 }
Пример #2
0
        // =========================================================================================
        // Methods
        // =========================================================================================

        /// <summary>
        /// Sets up the macros list view.
        /// </summary>
        /// <param name="buildMacros">The collection of build macros to add to the list.</param>
        public void InitializeMacroList(XBuildMacroCollection buildMacros)
        {
            this.macrosListView.Items.Clear();

            foreach (XBuildMacroCollection.MacroNameValuePair pair in buildMacros)
            {
                ListViewItem item = new ListViewItem(new string[] { pair.MacroName, pair.Value }, 0);
                this.macrosListView.Items.Add(item);
            }

            this.macrosListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
        }
        // =========================================================================================
        // Constructors
        // =========================================================================================

        /// <summary>
        /// Initializes a new instance of the <see cref="XSharpBuildMacros"/> class.
        /// </summary>
        /// <param name="project">The project from which to read the properties.</param>
        public XBuildMacroCollection(ProjectNode project)
        {
            XHelperMethods.VerifyNonNullArgument(project, "project");

            // get the global SolutionX properties
            XBuildMacroCollection.DefineSolutionProperties(project);
            foreach (string globalMacroName in globalMacroNames)
            {
                string property = null;
                project.BuildProject.GlobalProperties.TryGetValue(globalMacroName, out property);
                if (null == property)
                {
                    this.list.Add(globalMacroName, "*Undefined*");
                }
                else
                {
                    this.list.Add(globalMacroName, property);
                }
            }
            // we need to call GetTargetPath first so that TargetDir and TargetPath are resolved correctly
            ConfigCanonicalName configCanonicalName;

            if (!Utilities.TryGetActiveConfigurationAndPlatform(project.Site, project, out configCanonicalName))
            {
                throw new InvalidOperationException();
            }
            BuildResult res = project.Build(configCanonicalName, XProjectFileConstants.GetTargetPath);

            // get the ProjectX and TargetX variables
            foreach (string macroName in macroNames)
            {
                string value;
                ThreadHelper.ThrowIfNotOnUIThread();
                if (res.ProjectInstance != null)
                {
                    value = res.ProjectInstance.GetPropertyValue(macroName);
                }
                else
                {
                    value = project.GetProjectProperty(macroName);
                }

                this.list.Add(macroName, value);
            }
        }
Пример #4
0
        protected void showMacroDialog(TextBox tb, string caption, string filter = "")
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            var form = new XSharpSLEPropertyForm();

            if (!string.IsNullOrEmpty(filter))
            {
                form.Filter = filter;
            }
            XBuildMacroCollection mc = new XBuildMacroCollection((ProjectNode)this.ParentPropertyPage.ProjectMgr);

            form.SetMacros(mc);
            form.PropertyText.Text = tb.Text;
            form.Text = caption;
            var result = form.ShowDialog();

            if (result == DialogResult.OK)
            {
                tb.Text = form.PropertyText.Text;
                this.ParentPropertyPage.SetProperty((string)tb.Tag, tb.Text);
            }
        }
Пример #5
0
        /// <summary>
        /// Shows the editor form, which contains advanced editing features.
        /// </summary>
        /// <param name="sender">The edit button.</param>
        /// <param name="e">The <see cref="EventArgs"/> object that contains the event data.</param>
        private void OnEditButtonClick(object sender, EventArgs e)
        {
            // set the form's caption and text box
            this.EditorForm.Text       = this.EditorFormText;
            this.EditorForm.EditorText = this.contentTextBox.Text;

            // get the build macros currently defined - we do this every time rather than caching
            // the results because the configuration could change without us knowing about it.
            XBuildMacroCollection buildMacros = new XBuildMacroCollection(this.project);

            this.EditorForm.InitializeMacroList(buildMacros);

            // show the dialog and get the text back
            DialogResult result = this.editorForm.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                this.contentTextBox.Text     = this.editorForm.EditorText;
                this.contentTextBox.Modified = true;
                this.contentTextBox.Select(this.contentTextBox.Text.Length, 0);
                this.contentTextBox.Focus();
            }
        }