private bool IsHelpLocaleBookInstalled(BuildContext context) { BuildSettings settings = context.Settings; BuildFeedback feedback = settings.Feedback; string companyName = feedback.CompanyName; string productName = feedback.ProductName; string bookName = settings.HelpTitle; string locale = settings.CultureInfo.Name.ToLower(); string fileName = Path.GetFileName(_helpPath); return(this.IsHelpLocaleBookInstalled(companyName, productName, bookName, locale, fileName)); }
/// <summary> /// The creates the configuration information or settings required by the /// target component for the build process. /// </summary> /// <param name="group"> /// A build group, <see cref="BuildGroup"/>, representing the documentation /// target for configuration. /// </param> /// <param name="writer"> /// An <see cref="XmlWriter"/> object used to create one or more new /// child nodes at the end of the list of child nodes of the current node. /// </param> /// <returns> /// Returns <see langword="true"/> for a successful configuration; /// otherwise, it returns <see langword="false"/>. /// </returns> /// <remarks> /// The <see cref="XmlWriter"/> writer passed to this configuration object /// may be passed on to other configuration objects, so do not close or /// dispose it. /// </remarks> public override bool Configure(BuildGroup group, XmlWriter writer) { BuildExceptions.NotNull(group, "group"); BuildExceptions.NotNull(writer, "writer"); if (!this.Enabled || !this.IsInitialized) { return(false); } Debug.Assert(_settings != null, "The settings object is required."); if (_settings == null || _context == null) { return(false); } BuildGroupContext groupContext = _context.GroupContexts[group.Id]; if (groupContext == null) { throw new BuildException( "The group context is not provided, and it is required by the build system."); } //<component type="Sandcastle.Components.ReferencePostTransComponent" assembly="$(SandAssistComponent)"> // <paths outputPath=".\Output\"/> // <attributes> // <attribute name="DocSet" value="NETFramework" /> // <attribute name="DocSet" value="NETCompactFramework"/> // </attributes> // <scripts> // <IncludeItem item="assistScripts" /> // </scripts> // <styles> // <!-- Include the various styles used by the Sandcastle Assist --> // <IncludeItem item="codeStyle" /> // <IncludeItem item="assistStyle" /> // </styles> // <header> // <!-- Include the logo image support --> // <IncludeItem item="logoImage" /> // <!--<tables> // <table name="" operation="" /> // </tables>--> // </header> //</component> BuildFeedback feeback = _settings.Feedback; Debug.Assert(feeback != null, "Feedback object cannot be null (or Nothing)."); if (feeback == null) { return(false); } BuildStyle buildStyle = _settings.Style; Debug.Assert(buildStyle != null, "The style object cannot be null (or Nothing)."); if (buildStyle == null) { return(false); } writer.WriteStartElement("paths"); //start: paths writer.WriteAttributeString("outputPath", @".\Output\"); writer.WriteEndElement(); //end: paths AttributeContent attributes = _settings.Attributes; if (attributes != null && attributes.Count != 0) { writer.WriteStartElement("attributes"); //start: attributes for (int i = 0; i < attributes.Count; i++) { AttributeItem attribute = attributes[i]; if (attribute.IsEmpty) { continue; } writer.WriteStartElement("attribute"); //start: attribute writer.WriteAttributeString("name", attribute.Name); writer.WriteAttributeString("value", attribute.Value); writer.WriteEndElement(); //end: attribute } writer.WriteEndElement(); //end: attributes } writer.WriteStartElement("scripts"); //start: scripts ScriptContent scriptContent = buildStyle.Scripts; if (scriptContent != null && !scriptContent.IsEmpty) { for (int i = 0; i < scriptContent.Count; i++) { ScriptItem scriptItem = scriptContent[i]; // a. Empty item is no use. // b. Overriding scripts are added to the documentation // by the transform. if (scriptItem.IsEmpty || scriptItem.Overrides) { continue; } writer.WriteStartElement("script"); //start: script writer.WriteAttributeString("file", scriptItem.ScriptFile); writer.WriteAttributeString("condition", scriptItem.Condition); writer.WriteEndElement(); //end: script } } writer.WriteEndElement(); //end: scripts writer.WriteStartElement("styles"); //start: styles StyleSheetContent styleContent = buildStyle.StyleSheets; if (styleContent != null && !styleContent.IsEmpty) { for (int i = 0; i < styleContent.Count; i++) { StyleSheetItem styleItem = styleContent[i]; // a. Empty item is no use. // b. Overriding styles are added to the documentation // by the transform. if (styleItem.IsEmpty || styleItem.Overrides) { continue; } writer.WriteStartElement("style"); //start: style writer.WriteAttributeString("file", styleItem.StyleFile); writer.WriteAttributeString("condition", styleItem.Condition); writer.WriteEndElement(); //end: style } } writer.WriteEndElement(); //end: styles // Let the Feedback option object configure itself... feeback.Configure(group, writer); // Write roots to namespaces conversion handler... writer.WriteStartElement("rootNamespaces"); // start: rootNamespaces writer.WriteAttributeString("id", group.Id); string rootNamespacesFile = Path.Combine(_context.WorkingDirectory, groupContext["$RootNamespaces"]); if (File.Exists(rootNamespacesFile)) { writer.WriteAttributeString("source", rootNamespacesFile); } writer.WriteEndElement(); //end: rootNamespaces return(true); }
private void CreateMsha(BuildContext context) { string helpMshaPath = Path.Combine(_helpOutputDir, HelpContentSetup); BuildSettings settings = context.Settings; BuildFeedback feedback = settings.Feedback; string companyName = feedback.CompanyName; string productName = feedback.ProductName; string displayedName = settings.HelpTitle; XmlWriterSettings readerSettings = new XmlWriterSettings(); readerSettings.OmitXmlDeclaration = true; readerSettings.Indent = true; readerSettings.IndentChars = " "; readerSettings.Encoding = Encoding.UTF8; using (XmlWriter xmlWriter = XmlWriter.Create(helpMshaPath, readerSettings)) { xmlWriter.WriteStartDocument(); xmlWriter.WriteStartElement("html", "http://www.w3.org/1999/xhtml"); // html xmlWriter.WriteStartElement("head"); //head xmlWriter.WriteStartElement("title"); // title xmlWriter.WriteString(displayedName); xmlWriter.WriteEndElement(); //title xmlWriter.WriteEndElement(); // head xmlWriter.WriteStartElement("body"); xmlWriter.WriteAttributeString("class", "vendor-book"); xmlWriter.WriteStartElement("div"); //div - details xmlWriter.WriteAttributeString("class", "details"); xmlWriter.WriteStartElement("span"); // span xmlWriter.WriteAttributeString("class", "vendor"); xmlWriter.WriteString(companyName); //must be unique, will be installed dir-name. xmlWriter.WriteEndElement(); // span xmlWriter.WriteStartElement("span"); // span xmlWriter.WriteAttributeString("class", "locale"); xmlWriter.WriteString(settings.CultureInfo.Name.ToLower()); xmlWriter.WriteEndElement(); // span xmlWriter.WriteStartElement("span"); // span xmlWriter.WriteAttributeString("class", "product"); xmlWriter.WriteString(productName); xmlWriter.WriteEndElement(); // span xmlWriter.WriteStartElement("span"); // span xmlWriter.WriteAttributeString("class", "name"); xmlWriter.WriteString(displayedName); xmlWriter.WriteEndElement(); // span xmlWriter.WriteEndElement(); // div - details xmlWriter.WriteStartElement("div"); //div - package-list xmlWriter.WriteAttributeString("class", "package-list"); xmlWriter.WriteStartElement("div"); //div - package xmlWriter.WriteAttributeString("class", "package"); // List out all the packages - only one in this case... xmlWriter.WriteStartElement("span"); // span xmlWriter.WriteAttributeString("class", "name"); xmlWriter.WriteString(_helpName); xmlWriter.WriteEndElement(); // span xmlWriter.WriteStartElement("a"); // a xmlWriter.WriteAttributeString("class", "current-link"); xmlWriter.WriteAttributeString("href", _helpName + ".mshc"); xmlWriter.WriteString(_helpName + ".mshc"); xmlWriter.WriteEndElement(); // a xmlWriter.WriteEndElement(); // div - package xmlWriter.WriteEndElement(); // div - package-list xmlWriter.WriteEndElement(); // body xmlWriter.WriteEndElement(); // html xmlWriter.WriteEndDocument(); } }
private bool InstallHelpFile(BuildContext context) { BuildLogger logger = context.Logger; BuildSettings settings = context.Settings; BuildFeedback feedback = settings.Feedback; // The installation command line options... string installFormat = "/product {0} /version {1} /locale {2} /sourceMedia \"{3}\""; try { string companyName = feedback.CompanyName; string productName = feedback.ProductName; string bookName = settings.HelpTitle; if (logger != null) { logger.WriteLine(String.Format( "Installing: Company={0}, Product={1}, Book={2}", companyName, productName, bookName), BuildLoggerLevel.Info); } string installArguments = String.Format(installFormat, _catalogProductId, _catalogVersion, _catalogLocale, _helpSetup); Process proc = new Process(); proc.EnableRaisingEvents = false; proc.StartInfo.FileName = _helpLibManagerPath; proc.StartInfo.Arguments = installArguments; if (Environment.OSVersion.Version.Major >= 6) // Vista/Window7 { proc.StartInfo.UseShellExecute = true; proc.StartInfo.Verb = "runas"; } proc.Start(); proc.WaitForExit(); int exitCode = proc.ExitCode; proc.Close(); if (exitCode != 0) { ReportInstallAgentError(exitCode); return(false); } else { // Verify the successful installation. // Even with an indication of success, the Help Library // Manager process might have being cancelled... if (this.IsHelpLocaleBookInstalled(context)) { if (logger != null) { logger.WriteLine("The installation was successful.", BuildLoggerLevel.Info); } return(true); } else { if (logger != null) { logger.WriteLine("The installation failed. The installation is probably cancelled.", BuildLoggerLevel.Error); } return(false); } } } catch (Exception ex) { if (logger != null) { logger.WriteLine(ex, BuildLoggerLevel.Error); } return(false); } }
private bool UninstallHelpFile(BuildContext context) { BuildLogger logger = context.Logger; BuildSettings settings = context.Settings; BuildFeedback feedback = settings.Feedback; string uninstallFormat = "/product {0} /version {1} /locale {2} /uninstall /silent /vendor \"{3}\" /mediaBookList \"{4}\" /productName \"{5}\""; try { string companyName = feedback.CompanyName; string productName = feedback.ProductName; string bookName = settings.HelpTitle; if (logger != null) { logger.WriteLine(String.Format( "Uninstalling: Company={0}, Product={1}, Book={2}", companyName, productName, bookName), BuildLoggerLevel.Info); } string uninstallArguments = String.Format(uninstallFormat, _catalogProductId, _catalogVersion, _catalogLocale, companyName, bookName, productName); Process proc = new Process(); proc.EnableRaisingEvents = false; proc.StartInfo.FileName = _helpLibManagerPath; proc.StartInfo.Arguments = uninstallArguments; if (Environment.OSVersion.Version.Major >= 6) // Vista/Window7 { proc.StartInfo.UseShellExecute = true; proc.StartInfo.Verb = "runas"; } proc.Start(); proc.WaitForExit(); int exitCode = proc.ExitCode; proc.Close(); if (exitCode == 0 || exitCode == 200) { if (logger != null) { if (exitCode == 0) { logger.WriteLine("The uninstallation is successful.", BuildLoggerLevel.Info); } else if (exitCode == 200) { logger.WriteLine("The specified book is not currently installed.", BuildLoggerLevel.Info); } } return(true); } ReportUninstallAgentError(exitCode); return(false); } catch (Exception ex) { if (logger != null) { logger.WriteLine(ex, BuildLoggerLevel.Error); } return(false); } }
public void Create() { bool useCustomStyles = true; BuildStyleType styleType = BuildStyleType.ClassicWhite; _settings.WorkingDirectory = new BuildDirectoryPath(_workingDir); _settings.CleanIntermediate = false; _settings.ShowPreliminary = true; _settings.Style.StyleType = styleType; //_settings.SyntaxType = BuildSyntaxType.None; _settings.HeaderText = "Header: This is the header text."; _settings.FooterText = "Footer: This is the footer text."; BuildFeedback feedBack = _settings.Feedback; feedBack.CompanyName = "Sandcastle Assist"; feedBack.ProductName = "Sandcastle Helpers"; feedBack.EmailAddress = "*****@*****.**"; feedBack.FeedbackType = BuildFeedbackType.None; feedBack.CopyrightText = "Copyright © 2007-2008 Sandcastle Assist. All Rights Reserved."; feedBack.CopyrightLink = "http://www.codeplex.com/SandAssist"; // Configure the logo image information... feedBack.LogoEnabled = true; // show it... feedBack.LogoImage = new BuildFilePath(Path.Combine(_sandAssistDir, "AssistLogo.jpg")); feedBack.LogoWidth = 64; feedBack.LogoHeight = 64; feedBack.LogoPadding = 3; feedBack.LogoText = "Sandcastle Assist"; feedBack.LogoLink = "http://www.codeplex.com/SandAssist"; feedBack.LogoAlignment = BuildLogoAlignment.Center; feedBack.LogoPlacement = BuildLogoPlacement.Right; // Configure the logging, we add some loggers by their names... BuildLogging logging = _settings.Logging; //logging.Verbosity = BuildLoggerVerbosity.Detailed; //logging.AddLogger(XmlLogger.LoggerName); //logging.AddLogger(HtmlLogger.LoggerName); ///logging.AddLogger(XamlLogger.LoggerName); logging.AddLogger(ConsoleLogger.LoggerName); BuildStyle style = _settings.Style; // Add direct code snippet root folder... SnippetContent snippets = style.Snippets; snippets.Add(new SnippetItem( Path.Combine(_sampleDir, "SampleSnippets"))); // Add some custom math packages and commands... MathPackageContent mathPackages = style.MathPackages; mathPackages.Add("picture", "calc"); mathPackages.Add("xy", "all", "knot", "poly"); MathCommandContent mathCommands = style.MathCommands; mathCommands.Add(@"\quot", @"\dfrac{\varphi \cdot X_{n, #1}}{\varphi_{#2} \times \varepsilon_{#1}}", 2); mathCommands.Add(@"\exn", @"(x+\varepsilon_{#1})^{#1}", 1); if (useCustomStyles) { string stylesDir = @"Presentations"; stylesDir = Path.GetFullPath(stylesDir); if (Directory.Exists(stylesDir)) { _settings.Style.Directory = new BuildDirectoryPath(stylesDir); } } FormatChm chmFormat = _settings.Formats[BuildFormatType.HtmlHelp1] as FormatChm; if (chmFormat != null) { chmFormat.Enabled = true; chmFormat.UseBinaryToc = false; chmFormat.Indent = true; } //FormatHxs hxsFormat = // _settings.Formats[BuildFormatType.HtmlHelp2] as FormatHxs; //if (hxsFormat != null) //{ // //hxsFormat.SeparateIndexFile = true; // hxsFormat.Enabled = true; // hxsFormat.Indent = true; //} //FormatMhv mhvFormat = // _settings.Formats[BuildFormatType.HtmlHelp3] as FormatMhv; //if (mhvFormat != null) //{ // mhvFormat.Enabled = true; // mhvFormat.Indent = true; //} //FormatWeb webFormat = // _settings.Formats[BuildFormatType.WebHelp] as FormatWeb; //if (webFormat != null) //{ // webFormat.Enabled = true; // webFormat.Indent = true; //} //_settings.HelpName = "HelpRegister"; //_settings.HelpTitle = "Sandcastle HelpRegister"; _settings.HelpName = "SandcastleHelpers"; _settings.HelpTitle = "Sandcastle Helpers Test Sample"; }