Пример #1
0
 public StepHxsBuilder()
     : this(String.Empty)
 {
     this.LogTitle = "Building Help 2.x contents";
     _lastLevel    = BuildLoggerLevel.None;
     _verbosity    = BuildLoggerVerbosity.None;
 }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BuildLogger"/> class
        /// with the specified log file name.
        /// </summary>
        /// <param name="logFileName">
        /// A string specifying the log file name.
        /// </param>
        protected BuildLogger(string logFileName)
        {
            if (logFileName != null)
            {
                logFileName = logFileName.Trim();
            }
            if (!String.IsNullOrEmpty(logFileName) &&
                Path.IsPathRooted(logFileName))
            {
                logFileName = Path.GetFileName(logFileName);
            }

            _isEnabled   = true;
            _keepLogFile = true;
            _logTitle    = String.Empty;
            _logFileName = logFileName;
            _encoding    = new UTF8Encoding();

            _verbosity = BuildLoggerVerbosity.Normal;

            //_prefixStarted = ResourcesEx.LogStarted + ": ";
            //_prefixInfo    = ResourcesEx.LogInfo + ": ";
            //_prefixWarn    = ResourcesEx.LogWarn + ": ";
            //_prefixError   = ResourcesEx.LogError + ": ";
            //_prefixEnded   = ResourcesEx.LogEnded + ": ";
            //_prefixRights  = ResourcesEx.LogCopyright + ": ";

            _prefixStarted = "Started: ";
            _prefixInfo    = "Info: ";
            _prefixWarn    = "Warn: ";
            _prefixError   = "Error: ";
            _prefixEnded   = "Ended: ";
            _prefixRights  = "Copyright: ";
        }
Пример #3
0
        /// <summary>
        /// Initializes this build step with the specified current build context
        /// of the build process. This prepares the build step for the task execution.
        /// </summary>
        /// <param name="context">
        /// An instance of the <see cref="BuildContext"/> class, specifying the current
        /// build context of the build process.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// If the <paramref name="context"/> is <see langword="null"/>.
        /// </exception>
        /// <seealso cref="BuildStep.IsInitialized"/>
        /// <seealso cref="BuildStep.Uninitialize()"/>
        public virtual void Initialize(BuildContext context)
        {
            BuildExceptions.NotNull(context, "context");

            _isInitialized = false;
            if (_beforeSteps != null && _beforeSteps.Enabled)
            {
                _beforeSteps.Initialize(context);

                if (!_beforeSteps.IsInitialized)
                {
                    return;
                }
            }

            if (_afterSteps != null && _afterSteps.Enabled)
            {
                _afterSteps.Initialize(context);

                if (!_afterSteps.IsInitialized)
                {
                    return;
                }
            }

            _context = context;
            if (_verbosity == BuildLoggerVerbosity.None)
            {
                _verbosity = _context.Settings.Logging.Verbosity;
            }

            _isInitialized = true;
        }
Пример #4
0
        public StepXslTransform()
        {
            _ignoreXsltWhitespace = true;

            this.LogTitle = "Applying Transformation";
            _lastLevel    = BuildLoggerLevel.None;
            _verbosity    = BuildLoggerVerbosity.None;
        }
Пример #5
0
 public BuildLogging()
 {
     _useFile   = true;
     _keepFile  = true;
     _fileName  = "HelpBuild.log";
     _verbosity = BuildLoggerVerbosity.Minimal;
     _loggers   = new BuildList <string>();
 }
Пример #6
0
 public HxCompError(BuildLogger logger)
 {
     _isSuccess = true;
     _logger    = logger;
     if (logger != null)
     {
         _verbosity = logger.Verbosity;
     }
 }
Пример #7
0
        public StepXslTransform(string workingDir, string fileName, string arguments)
            : base(workingDir, fileName, arguments)
        {
            _ignoreXsltWhitespace = true;

            this.LogTitle = "Applying Transformation";
            _lastLevel    = BuildLoggerLevel.None;
            _verbosity    = BuildLoggerVerbosity.None;
        }
Пример #8
0
 public BuildLogging(BuildLogging source)
     : base(source)
 {
     _useFile    = source._useFile;
     _keepFile   = source._keepFile;
     _fileName   = source._fileName;
     _verbosity  = source._verbosity;
     _loggers    = source._loggers;
     _outputPath = source._outputPath;
 }
Пример #9
0
        private void OnZipSaveProgress(object sender, SaveProgressEventArgs e)
        {
            BuildLogger          logger          = this.Context.Logger;
            BuildLoggerVerbosity loggerVerbosity = BuildLoggerVerbosity.Quiet;

            if (logger == null)
            {
                loggerVerbosity = logger.Verbosity;
            }

            switch (e.EventType)
            {
            case ZipProgressEventType.Saving_Started:
                if (logger != null)
                {
                    _totalFileSaved = 0;
                    logger.WriteLine("Started compression for MSHC",
                                     BuildLoggerLevel.Info);
                }
                break;

            case ZipProgressEventType.Saving_AfterWriteEntry:
                if (e.EntriesTotal > _totalFileSaved)
                {
                    _totalFileSaved = e.EntriesTotal;
                }
                if (logger != null && loggerVerbosity > BuildLoggerVerbosity.Normal)
                {
                    logger.WriteLine(String.Format("Saved {0}/{1}: {2}", e.EntriesSaved,
                                                   e.EntriesTotal, e.CurrentEntry.FileName),
                                     BuildLoggerLevel.Info);
                }
                break;

            case ZipProgressEventType.Saving_Completed:
                if (logger != null)
                {
                    logger.WriteLine(String.Format("Total of {0} files saved.",
                                                   _totalFileSaved), BuildLoggerLevel.Info);

                    logger.WriteLine("Completed compression for MSHC.",
                                     BuildLoggerLevel.Info);
                }
                break;

            default:
                break;
            }
        }
Пример #10
0
        public StepHxsBuilder(string workingDir)
            : base(workingDir)
        {
            _langId          = 1033;
            _helpFolder      = "MsdnHelp";
            _helpFileVersion = new Version(1, 0, 0, 0);

            _indexSort        = true;
            _indexMerge       = true;
            _indexAutoInclude = true;

            this.LogTitle = "Building Help 2.x contents";
            _lastLevel    = BuildLoggerLevel.None;
            _verbosity    = BuildLoggerVerbosity.None;
        }
Пример #11
0
        /// <summary>
        /// This provides un-initialization of the build step, and release any
        /// resources created in the initialization process.
        /// </summary>
        /// <remarks>
        /// It provides the build step the way to clean up resources allocated
        /// during the initialization and execution of the build step.
        /// </remarks>
        /// <seealso cref="BuildStep.IsInitialized"/>
        /// <seealso cref="BuildStep.Initialize(BuildContext)"/>
        public virtual void Uninitialize()
        {
            if (_beforeSteps != null && _beforeSteps.Enabled)
            {
                _beforeSteps.Uninitialize();
            }
            if (_afterSteps != null && _afterSteps.Enabled)
            {
                _afterSteps.Uninitialize();
            }

            _context       = null;
            _verbosity     = BuildLoggerVerbosity.None;
            _isInitialized = false;
        }
Пример #12
0
        protected override bool OnExecute(BuildContext context)
        {
            BuildLogger logger = context.Logger;

            if (logger != null)
            {
                _verbosity = logger.Verbosity;
            }

            if (_group == null)
            {
                throw new BuildException(
                          "The build group for this step is required.");
            }

            if (_group.GroupType == BuildGroupType.Reference)
            {
                if (!CreateConfiguration((ReferenceGroup)_group))
                {
                    return(false);
                }
            }
            else if (_group.GroupType == BuildGroupType.Conceptual)
            {
                if (!CreateConfiguration((ConceptualGroup)_group))
                {
                    return(false);
                }
            }

            bool buildResult = false;

            if (context.IsDirectSandcastle)
            {
                buildResult = this.RunDirectAssembler(context);
            }
            else
            {
                buildResult = base.OnExecute(context);

                if (buildResult && !String.IsNullOrEmpty(_lastMessage) &&
                    _lastMessage.StartsWith("Processed", StringComparison.OrdinalIgnoreCase))
                {
                    if (_logger != null && _lastLevel == BuildLoggerLevel.Info &&
                        _verbosity == BuildLoggerVerbosity.Normal &&
                        _verbosity != BuildLoggerVerbosity.Quiet)
                    {
                        _logger.WriteLine(_lastMessage, BuildLoggerLevel.Info);
                    }

                    int startIndex = _lastMessage.IndexOf("topics");

                    if (startIndex > 0)
                    {
                        int processedTopics;
                        if (Int32.TryParse(_lastMessage.Substring(9,
                                                                  startIndex - 9).Trim(), out processedTopics))
                        {
                            context.AddProcessedTopics(processedTopics);
                        }
                    }
                }
            }

            return(buildResult);
        }
Пример #13
0
        private void OnZipAddProgress(object sender, AddProgressEventArgs e)
        {
            BuildLogger          logger          = this.Context.Logger;
            BuildLoggerVerbosity loggerVerbosity = BuildLoggerVerbosity.Quiet;

            if (logger == null)
            {
                loggerVerbosity = logger.Verbosity;
            }

            switch (e.EventType)
            {
            case ZipProgressEventType.Adding_Started:
                if (logger != null)
                {
                    _totalFileEntries = 0;
                    logger.WriteLine("Started adding files for MSHC",
                                     BuildLoggerLevel.Info);
                }
                break;

            case ZipProgressEventType.Adding_AfterAddEntry:
                string fileEntry = e.CurrentEntry.FileName;
                if (e.EntriesTotal > _totalFileEntries)
                {
                    _totalFileEntries = e.EntriesTotal;
                }
                // <item name="R1.htm" date="Wed, 25 Nov 2009 22:43:01 GMT"
                //       content-type="text/html; charset=utf-8" />
                if (_metadataWriter != null && !e.CurrentEntry.IsDirectory)
                {
                    _metadataWriter.WriteStartElement("item");         // item
                    _metadataWriter.WriteAttributeString("name", fileEntry);
                    _metadataWriter.WriteAttributeString("date",
                                                         DateTime.Now.ToString("R")); //TODO: which date is this?
                    _metadataWriter.WriteAttributeString("content-type", GetContentType(fileEntry));
                    _metadataWriter.WriteEndElement();                                // item
                }
                if (logger != null && loggerVerbosity > BuildLoggerVerbosity.Normal)
                {
                    logger.WriteLine("Added: " + fileEntry,
                                     BuildLoggerLevel.Info);
                }
                break;

            case ZipProgressEventType.Adding_Completed:
                if (logger != null)
                {
                    // The additional file is the single metadata file added later...
                    logger.WriteLine(String.Format("Total of {0} files added.",
                                                   _totalFileEntries + 1), BuildLoggerLevel.Info);

                    logger.WriteLine("Completed adding files for MSHC",
                                     BuildLoggerLevel.Info);
                }
                break;

            default:
                break;
            }
        }
Пример #14
0
 public HxCompError(BuildLogger logger, BuildLoggerVerbosity verbosity)
 {
     _isSuccess = true;
     _logger    = logger;
     _verbosity = verbosity;
 }
Пример #15
0
        protected override bool OnExecute(BuildContext context)
        {
            string workingDir = this.WorkingDirectory;

            if (String.IsNullOrEmpty(workingDir))
            {
                throw new BuildException("A working directory is required.");
            }

            BuildTocContext tocContext = context.TocContext;
            string          tocFile    = tocContext.GetValue("$" + _buildFormat.Name);

            if (!String.IsNullOrEmpty(tocFile) && File.Exists(tocFile))
            {
                _helpToc = Path.GetFileName(tocFile);
            }

            if (String.IsNullOrEmpty(_helpName) || String.IsNullOrEmpty(_helpToc))
            {
                throw new BuildException("The required property values are set.");
            }

            _logger = context.Logger;
            if (_logger != null)
            {
                _verbosity = _logger.Verbosity;
            }

            bool buildResult = false;

            _settings = context.Settings;
            BuildFormatList formats = _settings.Formats;

            if (formats == null || formats.Count == 0)
            {
                return(buildResult);
            }
            FormatHxs hxsFormat =
                formats[BuildFormatType.HtmlHelp2] as FormatHxs;

            if (hxsFormat == null || hxsFormat.Enabled == false)
            {
                return(buildResult);
            }
            _buildFormat = hxsFormat;
            string helpTitleId = _helpTitleId;

            if (helpTitleId != null)
            {
                helpTitleId = helpTitleId.Trim();
            }
            if (String.IsNullOrEmpty(helpTitleId))
            {
                helpTitleId = _helpName;
            }
            _helpTitleId = helpTitleId;

            // We create a common XML Settings for all the writers...
            _xmlSettings                    = new XmlWriterSettings();
            _xmlSettings.Encoding           = Encoding.UTF8;
            _xmlSettings.Indent             = true;
            _xmlSettings.IndentChars        = "    ";
            _xmlSettings.OmitXmlDeclaration = false;
            _xmlSettings.CloseOutput        = true;

            buildResult = true;
            try
            {
                if (_helpCulture != null)
                {
                    _langId = _helpCulture.LCID;
                }

                // For these properties, we do not mind if set or there is error.
                string tmpText = _buildFormat["IndexAutoInclude"];
                if (String.IsNullOrEmpty(tmpText) == false)
                {
                    try
                    {
                        _indexAutoInclude = Convert.ToBoolean(tmpText);
                    }
                    catch
                    {
                    }
                }
                tmpText = _buildFormat["IndexSort"];
                if (String.IsNullOrEmpty(tmpText) == false)
                {
                    try
                    {
                        _indexSort = Convert.ToBoolean(tmpText);
                    }
                    catch
                    {
                    }
                }
                tmpText = _buildFormat["IndexMerge"];
                if (String.IsNullOrEmpty(tmpText) == false)
                {
                    try
                    {
                        _indexMerge = Convert.ToBoolean(tmpText);
                    }
                    catch
                    {
                    }
                }
                tmpText = _buildFormat["SampleInfo"];
                if (String.IsNullOrEmpty(tmpText) == false)
                {
                    try
                    {
                        _sampleInfo = Convert.ToBoolean(tmpText);
                    }
                    catch
                    {
                    }
                }

                _helpDir = Path.Combine(workingDir, _helpFolder);
                if (Directory.Exists(_helpDir) == false)
                {
                    Directory.CreateDirectory(_helpDir);
                }

                buildResult = CreateContents(context);
                if (buildResult == false)
                {
                    return(buildResult);
                }

                buildResult = CreateProject(context);
                if (buildResult == false)
                {
                    return(buildResult);
                }

                buildResult = CreateToc(context);
                if (buildResult == false)
                {
                    return(buildResult);
                }

                buildResult = CreateIndex(context);
            }
            catch (Exception ex)
            {
                if (_logger != null)
                {
                    _logger.WriteLine(ex, BuildLoggerLevel.Error);
                }

                buildResult = false;
            }

            return(buildResult);
        }
Пример #16
0
        public bool Run(BuildContext context)
        {
            int    lcid       = _options.LangID;
            string lcidText   = lcid.ToString();
            string workingDir = Path.Combine(_options.OutputDirectory, "html");

            _context = context;
            _logger  = context.Logger;
            if (_logger != null)
            {
                _verbosity = _logger.Verbosity;
            }

            string configFile = Path.Combine(context.SandcastleToolsDirectory,
                                             "DBCSFix.exe.config");

            if (!File.Exists(configFile))
            {
                return(false);
            }
            using (XmlReader reader = XmlReader.Create(configFile))
            {
                XmlNodeType nodeType = XmlNodeType.None;
                while (reader.Read())
                {
                    nodeType = reader.NodeType;
                    if (nodeType == XmlNodeType.Element)
                    {
                        if (String.Equals(reader.Name, "add"))
                        {
                            _appSettings.Add(reader.GetAttribute("key"),
                                             reader.GetAttribute("value"));
                        }
                    }
                    else if (nodeType == XmlNodeType.EndElement)
                    {
                        string nodeName = reader.Name;
                        if (String.Equals(nodeName, "appSettings") ||
                            String.Equals(nodeName, "configuration"))
                        {
                            break;
                        }
                    }
                }
            }

            // Step 1: Convert unsupported high-order chars to ASCII equivalents
            FormatChmEncoder chmEncoder = new FormatChmAsciiSubstitute(_appSettings);

            chmEncoder.Initialize(workingDir, lcidText);
            _listEncoders.Add(chmEncoder);

            // Step 2: For the non-English code-pages, we do more processing...
            if (lcid != 1033)
            {
                // Step 2-1: Convert unsupported chars to named entities
                chmEncoder = new FormatChmEntitiesSubstitute(_appSettings);
                chmEncoder.Initialize(workingDir, lcidText);
                _listEncoders.Add(chmEncoder);

                // Step 2-2: Convert charset declarations from UTF-8 to proper
                //           ANSI code-page value
                chmEncoder = new FormatChmCodepageSubstitute(_appSettings);
                chmEncoder.Initialize(workingDir, lcidText);
                _listEncoders.Add(chmEncoder);

                // Step 2-3: Convert char encodings from UTF-8 to ANSI
                FormatChmUtf8ToAnsiConverter chmConverter =
                    new FormatChmUtf8ToAnsiConverter(_appSettings);
                chmConverter.Initialize(workingDir, lcidText);
                _listEncoders.Add(chmConverter);

                _outputEncoding = chmConverter.OutputEncoding;
            }

            // Finally, process the files...
            Process(workingDir);

            return(true);
        }
Пример #17
0
        protected override bool OnExecute(BuildContext context)
        {
            BuildLogger logger = context.Logger;

            bool isDirectSandcastle = context.IsDirectSandcastle;

            if (isDirectSandcastle)
            {
                isDirectSandcastle = this.IsDirectSandcastle();
                // If the parameters are not directly provided, try parsing...
                if (!isDirectSandcastle)
                {
                    isDirectSandcastle = this.ParseDirectInput(logger);
                }
            }

            if (isDirectSandcastle)
            {
                bool buildResult = false;

                AppDomain transformDomain = null;

                try
                {
                    transformDomain = AppDomain.CreateDomain(
                        "Sandcastle.BuildTransformDomain");

                    SandcastleTransformTool transformProxy =
                        (SandcastleTransformTool)transformDomain.CreateInstanceAndUnwrap(
                            typeof(SandcastleTransformTool).Assembly.FullName,
                            typeof(SandcastleTransformTool).FullName);

                    transformProxy.IgnoreWhitespace = _ignoreXsltWhitespace;
                    transformProxy.InputFile        = _inputFile;
                    transformProxy.OutputFile       = _outputFile;
                    transformProxy.Arguments        = _xsltArguments;
                    transformProxy.TransformFiles   = _transformFiles;

                    buildResult = transformProxy.Run(context);
                }
                catch (Exception ex)
                {
                    logger.WriteLine(ex);
                }
                finally
                {
                    if (transformDomain != null)
                    {
                        AppDomain.Unload(transformDomain);
                        transformDomain = null;
                    }
                }

                return(buildResult);
            }
            else
            {
                Console.WriteLine("@@@@@@ Using Command-Lines @@@@@@");

                if (logger != null)
                {
                    _verbosity = logger.Verbosity;
                }

                bool buildResult = base.OnExecute(context);

                if (buildResult)
                {
                    // For the unexpected case of no argument options to the
                    // XslTransformer tool, the exit code is still 0...
                    if (_lastLevel == BuildLoggerLevel.Error)
                    {
                        return(false);
                    }
                }

                return(buildResult);
            }
        }
Пример #18
0
        private void ReadXmlGeneral(XmlReader reader)
        {
            string startElement = reader.Name;

            Debug.Assert(String.Equals(startElement, "propertyGroup"));
            Debug.Assert(String.Equals(reader.GetAttribute("name"), "General"));

            if (reader.IsEmptyElement)
            {
                return;
            }

            while (reader.Read())
            {
                if ((reader.NodeType == XmlNodeType.Element) && String.Equals(
                        reader.Name, "property", StringComparison.OrdinalIgnoreCase))
                {
                    string tempText = null;
                    switch (reader.GetAttribute("name").ToLower())
                    {
                    case "verbosity":
                        tempText = reader.ReadString();
                        if (!String.IsNullOrEmpty(tempText))
                        {
                            _verbosity = (BuildLoggerVerbosity)Enum.Parse(
                                typeof(BuildLoggerVerbosity), tempText, true);
                        }
                        break;

                    case "usefile":
                        tempText = reader.ReadString();
                        if (!String.IsNullOrEmpty(tempText))
                        {
                            _useFile = Convert.ToBoolean(tempText);
                        }
                        break;

                    case "keepfile":
                        tempText = reader.ReadString();
                        if (!String.IsNullOrEmpty(tempText))
                        {
                            _keepFile = Convert.ToBoolean(tempText);
                        }
                        break;

                    case "filename":
                        _fileName = reader.ReadString();
                        break;

                    default:
                        // Should normally not reach here...
                        throw new NotImplementedException(reader.GetAttribute("name"));
                    }
                }
                else if (reader.NodeType == XmlNodeType.EndElement)
                {
                    if (String.Equals(reader.Name, startElement, StringComparison.OrdinalIgnoreCase))
                    {
                        break;
                    }
                }
            }
        }
Пример #19
0
        protected override bool OnExecute(BuildContext context)
        {
            BuildLogger logger = context.Logger;

            if (logger != null)
            {
                _verbosity = logger.Verbosity;
            }

            string appName = Path.GetFileName(this.Application);

            if (String.Equals(appName, "hhc.exe",
                              StringComparison.OrdinalIgnoreCase))
            {
                // hhc.exe is different, returns 0 if an error occurs
                this.ExpectedExitCode = 1;
            }
            else
            {
                // Unlike the hhc.exe tool,  SbAppLocale.exe will return 0 on success.
                this.ExpectedExitCode = 0;
            }

            bool buildResult = base.OnExecute(context);

            // If the build is successful, we will need to handle the output...
            if (!buildResult || String.IsNullOrEmpty(_helpDirectory) ||
                String.IsNullOrEmpty(_helpFolder))
            {
                return(buildResult);
            }

            if (!Directory.Exists(_helpDirectory))
            {
                Directory.CreateDirectory(_helpDirectory);
            }
            string helpOutput = Path.Combine(_helpDirectory, _helpFolder);

            string workingDir = this.WorkingDirectory;

            if (_keepSources)
            {
                // If requested to keep the build sources, just move it to
                // the output directory...
                string compiledDir = Path.Combine(workingDir, _helpFolder);
                if (!Directory.Exists(compiledDir))
                {
                    return(buildResult);
                }
                if (Directory.Exists(helpOutput))
                {
                    DirectoryUtils.DeleteDirectory(helpOutput, true);
                }
                Directory.Move(compiledDir, helpOutput);

                string destHelpPath = Path.Combine(helpOutput, _helpName + ".chm");
                context.AddOutput(BuildFormatType.HtmlHelp1, destHelpPath);
            }
            else
            {
                if (!Directory.Exists(helpOutput))
                {
                    Directory.CreateDirectory(helpOutput);
                }
                string sourceHelpPath = Path.Combine(workingDir,
                                                     String.Format(@"{0}\{1}.chm", _helpFolder, _helpName));
                string destHelpPath = Path.Combine(helpOutput, _helpName + ".chm");
                if (File.Exists(sourceHelpPath))
                {
                    File.Copy(sourceHelpPath, destHelpPath, true);
                    File.SetAttributes(destHelpPath, FileAttributes.Normal);

                    context.AddOutput(BuildFormatType.HtmlHelp1, destHelpPath);
                }
                sourceHelpPath = Path.ChangeExtension(sourceHelpPath, ".log");
                if (File.Exists(sourceHelpPath))
                {
                    destHelpPath = Path.ChangeExtension(destHelpPath, ".log");
                    File.Copy(sourceHelpPath, destHelpPath, true);
                    File.SetAttributes(destHelpPath, FileAttributes.Normal);
                }
            }

            return(buildResult);
        }
Пример #20
0
        private void OnReferenceContentsItem(string keyword, XPathNavigator navigator)
        {
            BuildContext context = this.Context;

            ReferenceGroupContext groupContext =
                context.GroupContexts[_group.Id] as ReferenceGroupContext;

            if (groupContext == null)
            {
                throw new BuildException(
                          "The group context is not provided, and it is required by the build system.");
            }

            BuildFramework framework = groupContext.Framework;

            if (framework == null)
            {
                throw new BuildException("No valid framework is specified.");
            }
            BuildFrameworkKind kind = framework.FrameworkType.Kind;

            //<data base="%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\en\"
            //   recurse="false"  files="*.xml" />
            //<data files=".\Comments\Project.xml" />
            //<data files=".\Comments\TestLibrary.xml" />
            XmlWriter writer = navigator.InsertAfter();

            string warnOverride = "false";

            BuildLoggerVerbosity loggerVerbosity = _settings.Logging.Verbosity;

            if (loggerVerbosity == BuildLoggerVerbosity.Detailed ||
                loggerVerbosity == BuildLoggerVerbosity.Diagnostic ||
                loggerVerbosity == BuildLoggerVerbosity.Normal)
            {
                warnOverride = "true";
            }

            CultureInfo          culture     = _settings.CultureInfo;
            string               langName    = culture.TwoLetterISOLanguageName;
            IEnumerable <string> commentDirs = framework.CommentDirs;

            // Store all the framework directories here, we will use this to
            // eliminate adding comment files directly from these directories...
            HashSet <string> commentDirSet = new HashSet <string>(
                StringComparer.OrdinalIgnoreCase);

            if (commentDirs != null)
            {
                writer.WriteComment(" The following are the framework (.NET, Silverlight etc) comment file directories. ");
                if (kind == BuildFrameworkKind.Silverlight)
                {
                    this.WriteDataSources(writer, DataSourceType.Silverlight,
                                          String.Empty, framework.Version, true, true,
                                          langName, commentDirs);
                }
                else if (kind == BuildFrameworkKind.Portable)
                {
                    this.WriteDataSources(writer, DataSourceType.Portable,
                                          String.Empty, framework.Version, true, false,
                                          langName, commentDirs);
                }
                else if (kind == BuildFrameworkKind.ScriptSharp)
                {
                    this.WriteDataSources(writer, DataSourceType.ScriptSharp,
                                          String.Empty, framework.Version, true, false,
                                          langName, commentDirs);
                }
                else if (kind == BuildFrameworkKind.Compact)
                {
                    // For the compact framework, the comments files are all
                    // redirected to the system comment files...
                    BuildFramework latestFramework = BuildFrameworks.LatestFramework;
                    commentDirs = latestFramework.CommentDirs;

                    this.WriteDataSources(writer, DataSourceType.Framework,
                                          String.Empty, latestFramework.Version, true, false,
                                          langName, commentDirs);
                }
                else
                {
                    // Write the data source...
                    this.WriteDataSources(writer, DataSourceType.Framework,
                                          String.Empty, framework.Version, true, false,
                                          langName, commentDirs);
                }

                foreach (string commentDir in commentDirs)
                {
                    if (!Directory.Exists(commentDir))
                    {
                        continue;
                    }
                    string finalDir = null;
                    string langDir  = Path.Combine(commentDir, langName);
                    writer.WriteStartElement("data");  // start - data
                    if (Directory.Exists(langDir))
                    {
                        writer.WriteAttributeString("base", langDir);

                        finalDir = langDir;
                    }
                    else
                    {
                        writer.WriteAttributeString("base", commentDir);

                        finalDir = commentDir;
                    }
                    writer.WriteAttributeString("recurse", "false");
                    writer.WriteAttributeString("system", "true");
                    writer.WriteAttributeString("warnOverride", warnOverride);
                    writer.WriteAttributeString("files", "*.xml");
                    writer.WriteEndElement();          // end - data

                    if (!finalDir.EndsWith("\\"))
                    {
                        finalDir += "\\";
                    }

                    commentDirSet.Add(finalDir);
                }
            }

            IEnumerable <string> commentFiles = framework.CommentFiles;

            if (commentFiles != null)
            {
                writer.WriteComment(" The following are the framework (.NET, Silverlight etc) comment files. ");
                foreach (string commentFile in commentFiles)
                {
                    // Try to avoid adding comment files from known framework
                    // directories...
                    string commentDir = Path.GetDirectoryName(commentFile);
                    if (!commentDir.EndsWith("\\"))
                    {
                        commentDir += "\\";
                    }
                    if (commentDirSet.Contains(commentDir))
                    {
                        continue;
                    }

                    writer.WriteStartElement("data");
                    writer.WriteAttributeString("files", commentFile);
                    writer.WriteAttributeString("warnOverride", "false");
                    writer.WriteEndElement();
                }
            }

            IList <string> linkCommentFiles = groupContext.LinkCommentFiles;

            if (linkCommentFiles != null && linkCommentFiles.Count != 0)
            {
                writer.WriteComment(" The following are the dependent assembly comment files. ");
                for (int i = 0; i < linkCommentFiles.Count; i++)
                {
                    string linkCommentFile = linkCommentFiles[i];
                    // Try to avoid adding comment files from known framework
                    // directories...
                    string commentDir = Path.GetDirectoryName(linkCommentFile);
                    if (!commentDir.EndsWith("\\"))
                    {
                        commentDir += "\\";
                    }
                    if (commentDirSet.Contains(commentDir))
                    {
                        continue;
                    }

                    writer.WriteStartElement("data");
                    writer.WriteAttributeString("files", linkCommentFile);
                    writer.WriteAttributeString("warnOverride", "false");
                    writer.WriteEndElement();
                }
            }

            IList <string> targetCommentFiles = groupContext.CommentFiles;

            if (targetCommentFiles != null && targetCommentFiles.Count != 0)
            {
                writer.WriteComment(" The following are the target comment files. ");
                for (int i = 0; i < targetCommentFiles.Count; i++)
                {
                    writer.WriteStartElement("data");
                    writer.WriteAttributeString("files", targetCommentFiles[i]);
                    writer.WriteAttributeString("warnOverride", "false");
                    writer.WriteEndElement();
                }
            }

            writer.Close();
            navigator.DeleteSelf();
        }
Пример #21
0
 private void ConstructorDefaults()
 {
     _lastLevel    = BuildLoggerLevel.None;
     _verbosity    = BuildLoggerVerbosity.None;
     this.LogTitle = "Assembling a documentation.";
 }