Beispiel #1
0
 void OnInitBuild(BuildProcess process)
 {
     Process = process;
     Process.BuildStarted += OnBuildProcessStarted;
     Process.TaskStarted  += OnTaskStarted;
     Process.TaskDone     += OnTaskDone;
     Process.BuildDone    += OnBuildProcessDone;
     _logger.LogDebug($"OnInitBuild: {process.Name}");
 }
 private void OnInitBuild(RequestContext _, BuildProcess process)
 {
     _logger.LogDebug("OnInitBuild");
     _process             = process;
     _lastMessageTime     = DateTime.Now;
     process.TaskStarted += OnTaskStarted;
     process.TaskDone    += OnTaskDone;
     process.BuildDone   += OnBuildDone;
 }
        /// <summary>
        /// This method is used to initialize the plug-in at the start of the build process
        /// </summary>
        /// <param name="buildProcess">A reference to the current build process</param>
        /// <param name="configuration">The configuration data that the plug-in should use to initialize itself</param>
        public void Initialize(BuildProcess buildProcess, XPathNavigator configuration)
        {
            builder = buildProcess;

            var metadata = (HelpFileBuilderPlugInExportAttribute)this.GetType().GetCustomAttributes(
                typeof(HelpFileBuilderPlugInExportAttribute), false).First();

            builder.ReportProgress("{0} Version {1}\r\n{2}", metadata.Id, metadata.Version, metadata.Copyright);
        }
Beispiel #4
0
 protected virtual void OnBuildProcessDone()
 {
     _logger.LogDebug($"OnBuildProcessDone: {Process.Name}");
     Process.BuildStarted -= OnBuildProcessStarted;
     Process.TaskStarted  -= OnTaskStarted;
     Process.TaskDone     -= OnTaskDone;
     Process.BuildDone    -= OnBuildProcessDone;
     Process = null;
 }
        //=====================================================================

        /// <summary>
        /// This is called to build a project
        /// </summary>
        /// <param name="project">The project to build</param>
        /// <param name="workingPath">The working path for the project</param>
        /// <returns>Returns true if successful, false if not</returns>
        private bool BuildProject(SandcastleProject project, string workingPath)
        {
            BuildProcess buildProcess;

            lastBuildStep = BuildStep.None;

            builder.ReportProgress("\r\nBuilding {0}", project.Filename);

            try
            {
                project.Configuration = builder.CurrentProject.Configuration;
                project.Platform      = builder.CurrentProject.Platform;

                // For the plug-in, we'll override some project settings
                project.HtmlHelp1xCompilerPath = new FolderPath(builder.Help1CompilerFolder, true, project);
                project.WorkingPath            = new FolderPath(workingPath, true, project);
                project.OutputPath             = new FolderPath(workingPath + @"..\PartialBuildLog\", true, project);

                // If the current project has defined OutDir, pass it on to the sub-project.
                string outDir = builder.CurrentProject.MSBuildProject.GetProperty("OutDir").EvaluatedValue;

                if (!String.IsNullOrEmpty(outDir) && outDir != @".\")
                {
                    project.MSBuildOutDir = outDir;
                }

                // Run the partial build through the transformation step as we need the document model
                // applied and filenames added.
                buildProcess = new BuildProcess(project, PartialBuildType.TransformReflectionInfo)
                {
                    ProgressReportProvider = this,
                    CancellationToken      = builder.CancellationToken
                };

                // Since this is a plug-in, we'll run it synchronously rather than as a background task
                buildProcess.Build();

                lastBuildStep = buildProcess.CurrentBuildStep;

                // Add the list of the comments files in the other project to this build
                if (lastBuildStep == BuildStep.Completed)
                {
                    foreach (XmlCommentsFile comments in buildProcess.CommentsFiles)
                    {
                        builder.CommentsFiles.Insert(0, comments);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new BuilderException("ARL0006", String.Format(CultureInfo.InvariantCulture,
                                                                    "Fatal error, unable to compile project '{0}': {1}", project.Filename, ex.ToString()));
            }

            return(lastBuildStep == BuildStep.Completed);
        }
Beispiel #6
0
        void AddBuildStat(BuildProcess process)
        {
            var stat = new BuildStat(process.Name, _server.FindCurrentBuildArgs(), process.StartTime, process.WorkTime);

            foreach (var task in process.Tasks)
            {
                stat.Tasks.Add(new TaskStat(task.Node.Name, task.StartTime, task.EndTime - task.StartTime));
            }
            _container.Builds.Add(stat);
        }
        public void Initialize(BuildProcess buildProcess, XPathNavigator configuration)
        {
            builder = buildProcess;

            var metadata = (HelpFileBuilderPlugInExportAttribute)GetType()
                           .GetCustomAttributes(typeof(HelpFileBuilderPlugInExportAttribute), false)
                           .First();

            builder.ReportProgress(metadata.Id);
        }
        /// <summary>
        /// This method is used to initialize the plug-in at the start of the build process
        /// </summary>
        /// <param name="buildProcess">A reference to the current build process</param>
        /// <param name="configuration">The configuration data that the plug-in should use to initialize itself</param>
        public void Initialize(BuildProcess buildProcess, XElement configuration)
        {
            builder = buildProcess;

            var metadata = (HelpFileBuilderPlugInExportAttribute)this.GetType().GetCustomAttributes(
                typeof(HelpFileBuilderPlugInExportAttribute), false).First();

            builder.ReportProgress("{0} Version {1}\r\n{2}\r\n    This build will only generate IntelliSense " +
                                   "comments files.", metadata.Id, metadata.Version, metadata.Copyright);
        }
Beispiel #9
0
        //=====================================================================

        /// <summary>
        /// Do a partial build on load to gather new namespace information that
        /// isn't currently in the project's namespace list.
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void NamespacesDlg_Load(object sender, EventArgs e)
        {
            string tempPath;

            cboAssembly.Enabled = txtSearchText.Enabled = btnAll.Enabled =
                btnNone.Enabled = btnApplyFilter.Enabled = btnDelete.Enabled =
                    false;

            try
            {
                // Clone the project for the build and adjust its properties
                // for our needs.
                tempProject = new SandcastleProject(nsColl.Project, true);

                // The temporary project resides in the same folder as the
                // current project (by filename only, it isn't saved) to
                // maintain relative paths.  However, build output is stored
                // in a temporary folder and it keeps the intermediate files.
                tempProject.CleanIntermediates = false;
                tempPath = Path.GetTempFileName();

                File.Delete(tempPath);
                tempPath = Path.Combine(Path.GetDirectoryName(tempPath),
                                        "SHFBPartialBuild");

                if (!Directory.Exists(tempPath))
                {
                    Directory.CreateDirectory(tempPath);
                }

                tempProject.OutputPath = tempPath;

                buildProcess = new BuildProcess(tempProject, true);
                buildProcess.BuildStepChanged +=
                    new EventHandler <BuildProgressEventArgs>(
                        buildProcess_BuildStepChanged);
                buildProcess.BuildProgress +=
                    new EventHandler <BuildProgressEventArgs>(
                        buildProcess_BuildProgress);

                buildThread              = new Thread(new ThreadStart(buildProcess.Build));
                buildThread.Name         = "Namespace partial build thread";
                buildThread.IsBackground = true;
                buildThread.Start();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
                MessageBox.Show("Unable to build project to obtain " +
                                "API information.  Error: " + ex.Message,
                                Constants.AppName, MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Beispiel #10
0
        /// <summary>
        /// This method is used to initialize the plug-in at the start of the build process
        /// </summary>
        /// <param name="buildProcess">A reference to the current build process</param>
        /// <param name="configuration">The configuration data that the plug-in should use to initialize itself</param>
        public void Initialize(BuildProcess buildProcess, XElement configuration)
        {
            builder = buildProcess;

            var metadata = (HelpFileBuilderPlugInExportAttribute)this.GetType().GetCustomAttributes(
                typeof(HelpFileBuilderPlugInExportAttribute), false).First();

            builder.ReportProgress("{0} Version {1}\r\n{2}", metadata.Id, metadata.Version, metadata.Copyright);

            // TODO: Add your initialization code here such as reading the configuration data
        }
Beispiel #11
0
        /// <summary>
        /// This method is used to initialize the plug-in at the start of the
        /// build process.
        /// </summary>
        /// <param name="buildProcess">A reference to the current build
        /// process.</param>
        /// <param name="configuration">The configuration data that the plug-in
        /// should use to initialize itself.</param>
        public void Initialize(BuildProcess buildProcess,
                               XPathNavigator configuration)
        {
            builder = buildProcess;

            builder.ReportProgress("{0} Version {1}\r\n{2}\r\n",
                                   this.Name, this.Version, this.Copyright);

            // TODO: Add your initialization code here such as reading the
            // configuration data.
        }
        /// <summary>
        /// This method is used to initialize the plug-in at the start of the build process
        /// </summary>
        /// <param name="buildProcess">A reference to the current build process</param>
        /// <param name="configuration">The configuration data that the plug-in should use to initialize itself</param>
        public void Initialize(BuildProcess buildProcess, XElement configuration)
        {
            builder = buildProcess;

            var metadata = (HelpFileBuilderPlugInExportAttribute)this.GetType().GetCustomAttributes(
                typeof(HelpFileBuilderPlugInExportAttribute), false).First();

            builder.ReportProgress("{0} Version {1}\r\n{2}", metadata.Id, metadata.Version, metadata.Copyright);

            excludeElementEval = new MatchEvaluator(OnExcludeElement);
        }
Beispiel #13
0
        /// <summary>
        /// This method is used to initialize the plug-in at the start of the
        /// build process.
        /// </summary>
        /// <param name="buildProcess">A reference to the current build
        /// process.</param>
        /// <param name="configuration">The configuration data that the plug-in
        /// should use to initialize itself.</param>
        public void Initialize(BuildProcess buildProcess, XPathNavigator configuration)
        {
            XPathNavigator root;
            string         option;

            builder  = buildProcess;
            minParts = 2;

            builder.ReportProgress("{0} Version {1}\r\n{2}", this.Name, this.Version, this.Copyright);

            // The Hierarchical TOC plug-in is not compatible with MS Help Viewer output
            // and there is currently no fix available.  The problem is that the table of
            // contents is generated off of the help topics when the help viewer file is
            // installed and, since there are no physical topics for the namespace nodes
            // added to the intermediate TOC file by the plug-in, they do not appear in the
            // help file.  Updating the plug-in to support help viewer output would have
            // required more work than time would allow for this release.    If building
            // other output formats in which you want to use the plug-in, build them
            // separately from the MS Help Viewer output.
            if ((builder.CurrentProject.HelpFileFormat & HelpFileFormat.MSHelpViewer) != 0)
            {
                this.ExecutionPoints.Clear();

                builder.ReportWarning("HTP0002", "This build produces MS Help Viewer output with which the " +
                                      "Hierarchical TOC Plug-In is not compatible.  It will not be used in this build.");
            }
            else
            {
                // Load the configuration
                root = configuration.SelectSingleNode("configuration/toc");

                if (root != null)
                {
                    option = root.GetAttribute("minParts", String.Empty);

                    if (!String.IsNullOrEmpty(option))
                    {
                        minParts = Convert.ToInt32(option, CultureInfo.InvariantCulture);
                    }

                    if (minParts < 1)
                    {
                        minParts = 1;
                    }

                    option = root.GetAttribute("insertBelow", String.Empty);

                    if (!String.IsNullOrEmpty(option))
                    {
                        insertBelow = Convert.ToBoolean(option, CultureInfo.InvariantCulture);
                    }
                }
            }
        }
Beispiel #14
0
        /// <summary>
        /// This is used to create the conceptual content build configuration files
        /// </summary>
        /// <param name="builder">The build process</param>
        /// <remarks>This will create the companion files used to resolve conceptual links and the
        /// <strong>_ContentMetadata_.xml</strong> configuration file.  It will also merge the conceptual topics
        /// into the BuildAssembler manifest file.</remarks>
        public void CreateConfigurationFiles(BuildProcess builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            this.CreateCompanionFiles(builder);
            this.CreateContentMetadata(builder);
            this.MergeConceptualManifest(builder);
        }
Beispiel #15
0
        /// <summary>
        /// This method is used to initialize the plug-in at the start of the build process
        /// </summary>
        /// <param name="buildProcess">A reference to the current build process</param>
        /// <param name="configuration">The configuration data that the plug-in should use to initialize itself</param>
        public void Initialize(BuildProcess buildProcess, XElement configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            builder = buildProcess;

            var metadata = (HelpFileBuilderPlugInExportAttribute)this.GetType().GetCustomAttributes(
                typeof(HelpFileBuilderPlugInExportAttribute), false).First();

            builder.ReportProgress("{0} Version {1}\r\n{2}", metadata.Id, metadata.Version, metadata.Copyright);

            if (configuration.IsEmpty)
            {
                throw new BuilderException("DFP0001", "The DBCS Fix plug-in has not been configured yet");
            }

            var node = configuration.Element("sbAppLocale");

            if (node != null)
            {
                sbAppLocalePath = node.Attribute("path").Value;
            }

            if (String.IsNullOrWhiteSpace(sbAppLocalePath))
            {
                builder.ReportWarning("DFP0002", "A path to the Steel Bytes App Locale tool was not specified " +
                                      "and it will not be used for this build.");
            }
            else
            {
                // If relative, the path is relative to the project folder
                sbAppLocalePath = FilePath.RelativeToAbsolutePath(builder.ProjectFolder,
                                                                  builder.SubstitutionTags.TransformText(sbAppLocalePath));

                if (!File.Exists(sbAppLocalePath))
                {
                    throw new BuilderException("DFP0003", "Unable to locate SBAppLocale tool at " + sbAppLocalePath);
                }
            }

            // If not building HTML Help 1, there's nothing to do
            if ((builder.CurrentProject.HelpFileFormat & HelpFileFormats.HtmlHelp1) == 0)
            {
                executionPoints.Clear();
                builder.ReportWarning("DFP0007", "An HTML Help 1 file is not being built.  This plug-in will " +
                                      "not be ran.");
            }
        }
Beispiel #16
0
        //=====================================================================

        /// <summary>
        /// Shut down the build process thread and clean up on exit
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void PreviewTopicWindow_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (buildThread != null && buildThread.IsAlive)
            {
                if (MessageBox.Show("A build is currently taking place to " +
                                    "preview a topic.  Do you want to abort it and close this " +
                                    "form?", Constants.AppName, MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Question) == DialogResult.No)
                {
                    e.Cancel = true;
                    return;
                }

                try
                {
                    Cursor.Current = Cursors.WaitCursor;
                    timer.Stop();

                    if (buildThread != null)
                    {
                        buildThread.Abort();
                    }

                    while (buildThread != null && !buildThread.Join(1000))
                    {
                        Application.DoEvents();
                    }

                    System.Diagnostics.Debug.WriteLine("Thread stopped");
                }
                finally
                {
                    Cursor.Current = Cursors.Default;
                    buildThread    = null;
                    buildProcess   = null;
                }
            }

            if (sender == this && tempProject != null)
            {
                // Delete the temporary project's working files
                if (!String.IsNullOrEmpty(tempProject.OutputPath) && Directory.Exists(tempProject.OutputPath))
                {
                    Directory.Delete(tempProject.OutputPath, true);
                }

                GC.Collect(2);
                GC.WaitForPendingFinalizers();
                GC.Collect(2);
            }
        }
Beispiel #17
0
        /// <summary>
        /// This method is used to initialize the plug-in at the start of the build process
        /// </summary>
        /// <param name="buildProcess">A reference to the current build process</param>
        /// <param name="configuration">The configuration data that the plug-in should use to initialize itself</param>
        public void Initialize(BuildProcess buildProcess, XElement configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            builder = buildProcess;

            var metadata = (HelpFileBuilderPlugInExportAttribute)this.GetType().GetCustomAttributes(
                typeof(HelpFileBuilderPlugInExportAttribute), false).First();

            builder.ReportProgress("{0} Version {1}\r\n{2}", metadata.Id, metadata.Version, metadata.Copyright);

            // If the file format is Open XML, this plug-in is not supported and will not run
            if ((builder.CurrentProject.HelpFileFormat & HelpFileFormats.OpenXml) != 0)
            {
                builder.ReportWarning("BIP0005", "The bibliography plug-in is not supported in the Open XML " +
                                      "file format and will not run.");
                executionPoints = new List <ExecutionPoint>();
                return;
            }

            if (configuration.IsEmpty)
            {
                throw new BuilderException("BIP0001", "The Bibliography support plug-in has not been configured yet");
            }

            var node = configuration.Element("bibliography");

            if (node != null)
            {
                bibliographyFile = node.Attribute("path").Value;
            }

            if (String.IsNullOrWhiteSpace(bibliographyFile))
            {
                throw new BuilderException("BIP0002", "A path to the bibliography file is required");
            }

            // If relative, the path is relative to the project folder
            bibliographyFile = FilePath.RelativeToAbsolutePath(builder.ProjectFolder,
                                                               builder.SubstitutionTags.TransformText(bibliographyFile));

            if (!File.Exists(bibliographyFile))
            {
                throw new BuilderException("BIP0003", "Unable to locate bibliography file at " + bibliographyFile);
            }
        }
        /// <summary>
        /// This method is used to initialize the plug-in at the start of the build process
        /// </summary>
        /// <param name="buildProcess">A reference to the current build process</param>
        /// <param name="configuration">The configuration data that the plug-in should use to initialize itself</param>
        public void Initialize(BuildProcess buildProcess, XPathNavigator configuration)
        {
            XPathNavigator root, node;

            builder = buildProcess;

            var metadata = (HelpFileBuilderPlugInExportAttribute)this.GetType().GetCustomAttributes(
                typeof(HelpFileBuilderPlugInExportAttribute), false).First();

            builder.ReportProgress("{0} Version {1}\r\n{2}", metadata.Id, metadata.Version, metadata.Copyright);

            // If the file format is Open XML, this plug-in is not supported and will not run
            if ((builder.CurrentProject.HelpFileFormat & HelpFileFormats.OpenXml) != 0)
            {
                builder.ReportWarning("BIP0005", "The bibliography plug-in is not supported in the Open XML " +
                                      "file format and will not run.");
                executionPoints = new List <ExecutionPoint>();
                return;
            }

            root = configuration.SelectSingleNode("configuration");

            if (root.IsEmptyElement)
            {
                throw new BuilderException("BIP0001", "The Bibliography support plug-in has not been " +
                                           "configured yet");
            }

            node = root.SelectSingleNode("bibliography");

            if (node != null)
            {
                bibliographyFile = node.GetAttribute("path", String.Empty).Trim();
            }

            if (String.IsNullOrEmpty(bibliographyFile))
            {
                throw new BuilderException("BIP0002", "A path to the bibliography file is required");
            }

            // If relative, the path is relative to the project folder
            bibliographyFile = FilePath.RelativeToAbsolutePath(builder.ProjectFolder,
                                                               builder.TransformText(bibliographyFile));

            if (!File.Exists(bibliographyFile))
            {
                throw new BuilderException("BIP0003", "Unable to locate bibliography file at " + bibliographyFile);
            }
        }
Beispiel #19
0
        /// <summary>
        /// Merge the conceptual topic IDs into the BuildAssembler manifest file.
        /// </summary>
        /// <param name="builder">The build process</param>
        private void MergeConceptualManifest(BuildProcess builder)
        {
            string conceptualManifest = Path.Combine(builder.WorkingFolder, "ConceptualManifest.xml"),
                   referenceManifest  = Path.Combine(builder.WorkingFolder, "manifest.xml");

            builder.ReportProgress("    Merging topic IDs into manifest.xml");

            using (var writer = XmlWriter.Create(conceptualManifest, new XmlWriterSettings {
                Indent = true, CloseOutput = true
            }))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("topics");

                foreach (TopicCollection tc in this.Topics)
                {
                    foreach (Topic t in tc)
                    {
                        t.WriteManifest(writer, builder);
                    }
                }

                if (File.Exists(referenceManifest))
                {
                    foreach (var topic in ComponentUtilities.XmlStreamAxis(referenceManifest, "topic"))
                    {
                        writer.WriteStartElement("topic");

                        foreach (var attr in topic.Attributes())
                        {
                            writer.WriteAttributeString(attr.Name.LocalName, attr.Value);
                        }

                        writer.WriteEndElement();
                    }
                }

                writer.WriteEndElement();
                writer.WriteEndDocument();
            }

            if (File.Exists(referenceManifest))
            {
                File.Copy(referenceManifest, Path.ChangeExtension(referenceManifest, "old"), true);
            }

            File.Copy(conceptualManifest, referenceManifest, true);
            File.Delete(conceptualManifest);
        }
Beispiel #20
0
        /// <summary>
        /// This method is used to initialize the plug-in at the start of the
        /// build process.
        /// </summary>
        /// <param name="buildProcess">A reference to the current build
        /// process.</param>
        /// <param name="configuration">The configuration data that the plug-in
        /// should use to initialize itself.</param>
        public void Initialize(BuildProcess buildProcess, XPathNavigator configuration)
        {
            this.builder = buildProcess;

            var configRoot = configuration.SelectSingleNode("configuration");

            if (configRoot != null)
            {
                var node = configRoot.SelectSingleNode("targetLanguage");
                if (node != null)
                {
                    targetLanguage = node.InnerXml.Trim();
                }
            }
        }
Beispiel #21
0
        /// <summary>
        /// This method is used to initialize the plug-in at the start of the build process
        /// </summary>
        /// <param name="buildProcess">A reference to the current build process</param>
        /// <param name="configuration">The configuration data that the plug-in should use to initialize itself</param>
        /// <exception cref="BuilderException">This is thrown if the plug-in configuration is not valid</exception>
        public void Initialize(BuildProcess buildProcess, XElement configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            builder    = buildProcess ?? throw new ArgumentNullException(nameof(buildProcess));
            ajaxDocUrl = projectName = String.Empty;
            userCreds  = new UserCredentials();
            proxyCreds = new ProxyCredentials();

            var metadata = (HelpFileBuilderPlugInExportAttribute)this.GetType().GetCustomAttributes(
                typeof(HelpFileBuilderPlugInExportAttribute), false).First();

            builder.ReportProgress("{0} Version {1}\r\n{2}", metadata.Id, metadata.Version, metadata.Copyright);

            if (configuration.IsEmpty)
            {
                throw new BuilderException("ADP0001", "The AjaxDoc plug-in has not been configured yet");
            }

            var node = configuration.Element("ajaxDoc");

            if (node != null)
            {
                ajaxDocUrl      = node.Attribute("url").Value;
                projectName     = node.Attribute("project").Value;
                regenerateFiles = (bool)node.Attribute("regenerate");
            }

            userCreds  = UserCredentials.FromXml(configuration);
            proxyCreds = ProxyCredentials.FromXml(configuration);

            if (ajaxDocUrl.Length == 0 || projectName.Length == 0 || (!userCreds.UseDefaultCredentials &&
                                                                      (userCreds.UserName.Length == 0 || userCreds.Password.Length == 0)) ||
                (proxyCreds.UseProxyServer && (proxyCreds.ProxyServer == null ||
                                               (!proxyCreds.Credentials.UseDefaultCredentials && (proxyCreds.Credentials.UserName.Length == 0 ||
                                                                                                  proxyCreds.Credentials.Password.Length == 0)))))
            {
                throw new BuilderException("ADP0002", "The AjaxDoc plug-in has an invalid configuration");
            }

            if (ajaxDocUrl[ajaxDocUrl.Length - 1] != '/')
            {
                ajaxDocUrl += "/";
            }
        }
Beispiel #22
0
        /// <summary>
        /// This is called to build a project
        /// </summary>
        /// <param name="project">The project to build</param>
        /// <param name="workingPath">The working path for the project</param>
        /// <returns>Returns true if successful, false if not</returns>
        private bool BuildProject(SandcastleProject project, string workingPath)
        {
            BuildProcess buildProcess;

            lastBuildStep = BuildStep.None;

            builder.ReportProgress("\r\nBuilding {0}", project.Filename);

            try
            {
                // For the plug-in, we'll override some project settings
                project.HtmlHelp1xCompilerPath = new FolderPath(builder.Help1CompilerFolder, true, project);
                project.HtmlHelp2xCompilerPath = new FolderPath(builder.Help2CompilerFolder, true, project);
                project.WorkingPath            = new FolderPath(workingPath, true, project);
                project.OutputPath             = new FolderPath(workingPath + @"..\PartialBuildLog\", true, project);

                // If the current project has defined OutDir, pass it on to the sub-project.
                string outDir = builder.CurrentProject.MSBuildProject.GetProperty("OutDir").EvaluatedValue;

                if (!String.IsNullOrEmpty(outDir) && outDir != @".\")
                {
                    project.MSBuildOutDir = outDir;
                }

                buildProcess = new BuildProcess(project, PartialBuildType.GenerateReflectionInfo);

                buildProcess.BuildStepChanged += buildProcess_BuildStepChanged;

                // Since this is a plug-in, we'll run it directly rather than in a background thread
                buildProcess.Build();

                // Add the list of the comments files in the other project to this build
                if (lastBuildStep == BuildStep.Completed)
                {
                    foreach (XmlCommentsFile comments in buildProcess.CommentsFiles)
                    {
                        builder.CommentsFiles.Insert(0, comments);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new BuilderException("VBP0004", String.Format(CultureInfo.InvariantCulture,
                                                                    "Fatal error, unable to compile project '{0}': {1}", project.Filename, ex.ToString()));
            }

            return(lastBuildStep == BuildStep.Completed);
        }
Beispiel #23
0
        /// <summary>
        /// Write out the <strong>BuildAssembler</strong> manifest entry
        /// </summary>
        /// <param name="writer">The XML writer to which the entry is written</param>
        /// <param name="builder">The build process</param>
        /// <remarks>This will recursively write out entries for sub-topics as well</remarks>
        internal void WriteManifest(XmlWriter writer, BuildProcess builder)
        {
            // MS Help Viewer doesn't support empty place holders so we automatically generate a dummy place
            // holder file for them.
            if (!noFile || (builder.CurrentProject.HelpFileFormat & HelpFileFormats.MSHelpViewer) != 0)
            {
                writer.WriteStartElement("topic");
                writer.WriteAttributeString("id", this.Id);
                writer.WriteEndElement();
            }

            foreach (Topic t in subtopics)
            {
                t.WriteManifest(writer, builder);
            }
        }
Beispiel #24
0
        /// <summary>
        /// This method is used to initialize the plug-in at the start of the
        /// build process.
        /// </summary>
        /// <param name="buildProcess">A reference to the current build
        /// process.</param>
        /// <param name="configuration">The configuration data that the plug-in
        /// should use to initialize itself.</param>
        public void Initialize(BuildProcess buildProcess, XPathNavigator configuration)
        {
            XPathNavigator root, node;

            builder = buildProcess;

            builder.ReportProgress("{0} Version {1}\r\n{2}", this.Name, this.Version, this.Copyright);

            root = configuration.SelectSingleNode("configuration");

            if (root.IsEmptyElement)
            {
                throw new BuilderException("DFP0001", "The DBCS Fix plug-in " +
                                           "has not been configured yet");
            }

            node = root.SelectSingleNode("sbAppLocale");

            if (node != null)
            {
                sbAppLocalePath = node.GetAttribute("path", String.Empty).Trim();
            }

            if (String.IsNullOrEmpty(sbAppLocalePath))
            {
                throw new BuilderException("DFP0002", "A path to the Steel " +
                                           "Bytes App Locale tool is required");
            }

            // If relative, the path is relative to the project folder
            sbAppLocalePath = FilePath.RelativeToAbsolutePath(
                builder.ProjectFolder, builder.TransformText(sbAppLocalePath));

            if (!File.Exists(sbAppLocalePath))
            {
                throw new BuilderException("DFP0003", "Unable to locate " +
                                           "SBAppLocale tool at " + sbAppLocalePath);
            }

            // If not building HTML Help 1, there's nothing to do
            if ((builder.CurrentProject.HelpFileFormat & HelpFileFormat.HtmlHelp1) == 0)
            {
                executionPoints.Clear();
                builder.ReportWarning("DFP0007", "An HTML Help 1 file is not " +
                                      "being built.  This plug-in will not be ran.");
            }
        }
Beispiel #25
0
        /// <summary>
        /// This method is used to initialize the plug-in at the start of the
        /// build process.
        /// </summary>
        /// <param name="buildProcess">A reference to the current build
        /// process.</param>
        /// <param name="configuration">The configuration data that the plug-in
        /// should use to initialize itself.</param>
        /// <exception cref="BuilderException">This is thrown if the plug-in
        /// configuration is not valid.</exception>
        public void Initialize(BuildProcess buildProcess,
                               XPathNavigator configuration)
        {
            XPathNavigator root, node;

            builder    = buildProcess;
            ajaxDocUrl = projectName = String.Empty;
            userCreds  = new UserCredentials();
            proxyCreds = new ProxyCredentials();

            builder.ReportProgress("{0} Version {1}\r\n{2}",
                                   this.Name, this.Version, this.Copyright);

            root = configuration.SelectSingleNode("configuration");

            if (root.IsEmptyElement)
            {
                throw new BuilderException("ADP0001", "The AjaxDoc plug-in " +
                                           "has not been configured yet");
            }

            node = root.SelectSingleNode("ajaxDoc");
            if (node != null)
            {
                ajaxDocUrl      = node.GetAttribute("url", String.Empty).Trim();
                projectName     = node.GetAttribute("project", String.Empty).Trim();
                regenerateFiles = Convert.ToBoolean(node.GetAttribute(
                                                        "regenerate", String.Empty), CultureInfo.InvariantCulture);
            }

            userCreds  = UserCredentials.FromXPathNavigator(root);
            proxyCreds = ProxyCredentials.FromXPathNavigator(root);

            if (ajaxDocUrl.Length == 0 || projectName.Length == 0 ||
                (!userCreds.UseDefaultCredentials &&
                 (userCreds.UserName.Length == 0 ||
                  userCreds.Password.Length == 0)) ||
                (proxyCreds.UseProxyServer &&
                 (proxyCreds.ProxyServer == null ||
                  (!proxyCreds.Credentials.UseDefaultCredentials &&
                   (proxyCreds.Credentials.UserName.Length == 0 ||
                    proxyCreds.Credentials.Password.Length == 0)))))
            {
                throw new BuilderException("ADP0002", "The AjaxDoc plug-in " +
                                           "has an invalid configuration");
            }
        }
Beispiel #26
0
        static void editHtmlFolder(BuildProcess builder, string path, HelpFileFormats format)
        {
            string[] htmlFilesPaths = Directory.GetFiles(path, "*.htm", SearchOption.TopDirectoryOnly);
            // Then we classify the Files into different types
            List <Tuple <string, FileType> > filesWithType = new List <Tuple <string, FileType> >(htmlFilesPaths.Length);

            foreach (string htmlFilePath in htmlFilesPaths)
            {
                string htmlFileName = htmlFilePath.Remove(0, path.Length + 1); // +1 comes from backslash character in the path ending.
                htmlFileName = htmlFileName.Remove(htmlFileName.Length - 4);   // remove the .htm at the end of the string.
                FileType htmlType = findFileType(htmlFileName);
                //if (htmlType != FileType.other)
                //{
                //    Console.WriteLine(htmlFileName + "  |  " + htmlType);
                //}
                Tuple <string, FileType> fileWithType = new Tuple <string, FileType>(htmlFilePath, htmlType);
                filesWithType.Add(fileWithType);
            }
            //edit each html page
            int counter = 0;

            foreach (Tuple <string, FileType> fileWithType in filesWithType)
            {
                string   fileName = fileWithType.Item1;
                FileType filetype = fileWithType.Item2;
                // edit the page itself
                editPage(fileName, filetype);
                // edit all the typeNames on the page
                editForTypeNames(fileWithType.Item1);
                if (format == HelpFileFormats.MSHelpViewer)
                {
                    editFileForMSHV(fileName, filetype);
                }
                else if (format == HelpFileFormats.Website)
                {
                    editWebsiteToc(fileName);
                }
                counter++;
                if (counter % 500 == 0)
                {
                    builder.ReportProgress("   Adjusted {0} pages", counter);
                }
            }
            builder.ReportProgress("   Finished adjusting {0} pages", counter);
            return;
        }
Beispiel #27
0
        //=====================================================================

        /// <summary>
        /// This is called by the build process thread to update the main window with the current build step
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void buildProcess_BuildStepChanged(object sender, BuildProgressEventArgs e)
        {
            if (this.InvokeRequired)
            {
                try
                {
                    // Ignore it if we've already shut down or it hasn't completed yet
                    if (!this.IsDisposed)
                    {
                        this.Invoke(new EventHandler <BuildProgressEventArgs>(buildProcess_BuildStepChanged),
                                    new object[] { sender, e });
                    }
                }
                catch (Exception)
                {
                    // Ignore these as we still get one occasionally due to the object being disposed or the
                    // handle not being valid even though we do check for it first.
                }
            }
            else
            {
                lblProgress.Text = e.BuildStep.ToString();

                if (e.HasCompleted)
                {
                    // Switch back to the current project's folder
                    Directory.SetCurrentDirectory(Path.GetDirectoryName(nsColl.Project.Filename));

                    // If successful, load the namespace nodes, and enable the UI
                    if (e.BuildStep == BuildStep.Completed)
                    {
                        this.LoadNamespaces(buildProcess.ReflectionInfoFilename);

                        cboAssembly.Enabled = txtSearchText.Enabled = btnApplyFilter.Enabled = btnAll.Enabled =
                            btnNone.Enabled = true;
                    }

                    pbWait.Visible = lblProgress.Visible = false;
                    lbNamespaces.Focus();

                    buildThread  = null;
                    buildProcess = null;
                }
            }
        }
Beispiel #28
0
        static void editHtmlFolder(BuildProcess builder, string path, HelpFileFormats format)
        {
            string[] htmlFilesPaths = Directory.GetFiles(path, "*.htm", SearchOption.TopDirectoryOnly);
            // Then we classify the Files into different types
            var filesWithType = new List <Tuple <string, FileType, string> >(htmlFilesPaths.Length);

            foreach (string htmlFilePath in htmlFilesPaths)
            {
                string htmlFileName = htmlFilePath.Remove(0, path.Length + 1); // +1 comes from backslash character in the path ending.
                htmlFileName = htmlFileName.Remove(htmlFileName.Length - 4);   // remove the .htm at the end of the string.
                FileType htmlType = findFileType(htmlFileName);
                string   strType  = "";
                if (htmlType == FileType.singleField)
                {
                    var contents = File.ReadAllText(htmlFilePath);
                    strType = determineFieldType(contents);
                }
                var fileWithType = new Tuple <string, FileType, string>(htmlFilePath, htmlType, strType);

                filesWithType.Add(fileWithType);
            }
            //edit each html page
            int counter = 0;

            foreach (var fileWithType in filesWithType)
            {
                string   fileName = fileWithType.Item1;
                FileType filetype = fileWithType.Item2;
                // edit the page itself
                editPage(fileName, filetype);
                // edit all the typeNames on the page
                editForTypeNames(fileWithType.Item1);
                if (format == HelpFileFormats.MSHelpViewer)
                {
                    editFileForMSHV(fileName, filetype, fileWithType.Item3);
                }
                counter++;
                if (counter % 500 == 0)
                {
                    builder.ReportProgress("   Adjusted {0} pages", counter);
                }
            }
            builder.ReportProgress("   Finished adjusting {0} pages", counter);
            return;
        }
Beispiel #29
0
        /// <summary>
        /// Write out the <b>BuildAssembler</b> manifest entry
        /// </summary>
        /// <param name="writer">The XML writer to which the entry is written</param>
        /// <param name="builder">The build process</param>
        /// <remarks>This will recursively write out entries for sub-topics
        /// as well.</remarks>
        internal void WriteManifest(XmlWriter writer, BuildProcess builder)
        {
            // MS Help Viewer doesn't support empty place holders so we automatically
            // generate a dummy place holder file for them.  Don't add an entry for
            // raw HTML files.
            if ((!noFile && topicFile.DocumentType != DocumentType.Html) ||
                (noFile && (builder.CurrentProject.HelpFileFormat & HelpFileFormats.MSHelpViewer) != 0))
            {
                writer.WriteStartElement("topic");
                writer.WriteAttributeString("id", this.Id);
                writer.WriteEndElement();
            }

            foreach (Topic t in subtopics)
            {
                t.WriteManifest(writer, builder);
            }
        }
        /// <summary>
        /// This method is used to initialize the plug-in at the start of the build process
        /// </summary>
        /// <param name="buildProcess">A reference to the current build process</param>
        /// <param name="configuration">The configuration data that the plug-in should use to initialize itself</param>
        public void Initialize(BuildProcess buildProcess, XPathNavigator configuration)
        {
            builder = buildProcess;

            var metadata = (HelpFileBuilderPlugInExportAttribute)this.GetType().GetCustomAttributes(
                typeof(HelpFileBuilderPlugInExportAttribute), false).First();

            builder.ReportProgress("{0} Version {1}\r\n{2}\r\n    This build will only include additional " +
                                   "content items.", metadata.Id, metadata.Version, metadata.Copyright);

            if (!builder.CurrentProject.HasItems(BuildAction.ContentLayout) &&
                !builder.CurrentProject.HasItems(BuildAction.SiteMap) &&
                !builder.CurrentProject.HasItems(BuildAction.Content))
            {
                throw new BuilderException("ACP0001", "The Additional Content Only plug-in requires a " +
                                           "conceptual content layout file, a site map file, or content items in the project.");
            }
        }
        private void WriteSimpleDotFile(BuildProcess process)
        {
            int nextID = 0;

            Console.WriteLine("digraph \"{0}\" {{", ProjectFile);
            Console.WriteLine("width=\"10\";");
            Console.WriteLine("height=\"9\";");
            foreach (BuildNode buildNode in process.RequiredNodes) {
                string nodeID = String.Format("n{0}", nextID);
                nextID++;
                Console.WriteLine("node [shape=box];");
                Console.WriteLine("{0} [label=\"{1}\"];",
                    nodeID,
                    buildNode.Translation.GetType().Name);

                Console.WriteLine("node [shape=ellipse]");
                foreach (string filePath in buildNode.GetAllInputs()) {
                    bool allowFile = AllowFile(filePath);
                    if (!allowFile) {
                        continue;
                    }

                    Console.WriteLine("\"{0}\" [label=\"{1}\"];",
                        filePath,
                        Path.GetFileName(filePath));
                    Console.WriteLine("\"{0}\" -> {1};", filePath, nodeID);
                }
                foreach (string filePath in buildNode.GetAllOutputs()) {
                    bool allowFile = AllowFile(filePath);
                    if (!allowFile) {
                        continue;
                    }

                    Console.WriteLine("\"{0}\" [label=\"{1}\"];",
                        filePath,
                        Path.GetFileName(filePath));
                    Console.WriteLine("{0} -> \"{1}\";", nodeID, filePath);
                }
            }
            Console.WriteLine("}");
        }