/// <summary> /// This is used to clean up the MS Help 2 collection files so that /// they are ready for use in registering the collection. /// </summary> private void CleanUpCollectionFiles() { XmlDocument document; XmlNode node; string extension, toc, iniFile; this.ReportProgress("Cleaning up collection files..."); foreach (string file in Directory.GetFiles(outputFolder, project.HtmlHelpName + "*.Hx?")) { extension = Path.GetExtension(file).ToLower( CultureInfo.InvariantCulture); switch (extension) { case ".hxc": document = BuildProcess.OpenCollectionFile(file); // Remove the compiler options node = document.SelectSingleNode( "HelpCollection/CompilerOptions"); if (node != null) { node.ParentNode.RemoveChild(node); } break; case ".hxt": // We don't need the whole TOC so recreate it from // this string. toc = this.TransformText( "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" + "<!DOCTYPE HelpTOC>\r\n" + "<HelpTOC DTDVersion=\"1.0\" LangId=\"{@LangId}\" " + "PluginStyle=\"{@CollectionTocStyle}\" " + "PluginTitle=\"{@HtmlEncHelpTitle}\">\r\n" + " <HelpTOCNode NodeType=\"TOC\" " + "Url=\"{@HTMLEncHelpName}\" />\r\n" + "</HelpTOC>\r\n"); document = new XmlDocument(); document.LoadXml(toc); break; case ".hxk": document = BuildProcess.OpenCollectionFile(file); break; default: // Ignore it (i.e. .HXS) document = null; break; } if (document != null) { document.Save(file); } } this.ReportProgress("Creating H2Reg.ini file..."); iniFile = outputFolder + project.HtmlHelpName + "_H2Reg.ini"; if (File.Exists(iniFile)) { File.Delete(iniFile); } this.TransformTemplate("Help2x_H2Reg.ini", templateFolder, outputFolder); File.Move(outputFolder + "Help2x_H2Reg.ini", iniFile); }