public override bool Execute() { if (!base.Execute()) { return(false); } BuildProject project = null; try { BuildDocumenter documenter = new BuildDocumenter(); documenter.DocumentFile = new BuildFilePath(this.SandcastleFile); documenter.Load(); if (documenter.IsEmpty) { this.Log.LogError(null, String.Empty, String.Empty, "Error", 0, 0, 0, 0, "The documentation is empty or has no valid content."); return(false); } BuildSettings settings = documenter.Settings; string outputPath = this.OutputPath; if (!String.IsNullOrEmpty(outputPath)) { Directory.CreateDirectory(outputPath); settings.WorkingDirectory = new BuildDirectoryPath(outputPath); } IList <string> loggers = this.Loggers; if (loggers != null && loggers.Count != 0) { BuildLogging logging = settings.Logging; for (int i = 0; i < loggers.Count; i++) { string logger = loggers[i]; if (!String.IsNullOrEmpty(logger)) { logging.AddLogger(logger); } } } // Create the project, with the documentation data, the type // of system and the type of build... project = new BuildProject(documenter, BuildSystem.MSBuild, Sandcastle.BuildType.Testing); // Initialize the project, if successful, build it... project.Initialize(this.BuildLogger); if (project.IsInitialized) { return(project.Build()); } else { this.Log.LogError(null, String.Empty, String.Empty, "Error", 0, 0, 0, 0, "Error in reference build initialization."); return(false); } } catch (Exception ex) { #if DEBUG this.Log.LogErrorFromException(ex, true); #else this.Log.LogErrorFromException(ex, false); #endif return(false); } finally { // Finally, un-initialize the project and dispose it... if (project != null) { project.Uninitialize(); project.Dispose(); project = null; } } }
static void Main(string[] args) { // This is our documentation content and settings definitions BuildDocumenter documenter = new BuildDocumenter(); Console.WriteLine("Installed Frameworks:"); IList <BuildFramework> frameworks = BuildFrameworks.InstalledFrameworks; for (int i = 0; i < frameworks.Count; i++) { BuildFramework framework = frameworks[i]; Console.WriteLine("\t{0}: {1} - {2} ... {3}", i, framework.Version, framework.FrameworkType, framework.AssemblyDir); //if (framework.FrameworkType.Kind == BuildFrameworkKind.Silverlight) //{ // Version version = framework.Version; // if (version.Major >= 5) // { // } //} } Console.WriteLine(); try { BuildSettings settings = documenter.Settings; // Customize the documentation settings... TestOptions options = new TestOptions(settings); // Create default test settings... options.Create(); // Prompt for content options... if (!options.Run()) { Console.WriteLine("--->>Exiting the build process.<<---"); Console.WriteLine(); return; } // Create the documentation contents... // The conceptual topics... ConceptualTopics.Create(documenter, options); // The reference topics... ReferenceTopics.Create(documenter, options); // The local reference topics... //LocalReferenceTopics.Create(documenter, options); // Create custom TOC, if necessary... TestTocOptions.Create(documenter, options); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } // If we get this far, the content is created and we will proceed // to build the help... BuildProject project = null; try { // Create the project, with the documentation data, the type // of system and the type of build... project = new BuildProject(documenter, BuildSystem.Console, BuildType.Testing); //project.TargetPlatform = "Win32"; //project.TargetConfiguration = "Debug"; // Initialize the project, if successful, build it... project.Initialize(); if (project.IsInitialized) { project.Build(); } else { Console.WriteLine( "Error in reference build initialization."); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { // Finally, un-initialize the project and dispose it... if (project != null) { project.Uninitialize(); project.Dispose(); project = null; } } }
static void Main(string[] args) { // This is our documentation content and settings definitions BuildDocumenter documenter = new BuildDocumenter(); BuildFilePath documentFile = null; bool loadIt = true; bool useMSBuild = false; string workingDir = null; try { BuildSettings settings = documenter.Settings; // Customize the documentation settings... TestOptions options = new TestOptions(settings); // Create default test settings... if (!loadIt) { options.Create(); } // Prompt for content options... if (!options.Run()) { Console.WriteLine("--->>Exiting the build process.<<---"); Console.WriteLine(); return; } workingDir = options.WorkingDir; if (!Directory.Exists(workingDir)) { Directory.CreateDirectory(workingDir); } if (loadIt) { documentFile = new BuildFilePath(Path.Combine( workingDir, "Documentation" + BuildFileExts.DocumentExt)); documenter.DocumentFile = documentFile; documenter.Load(); string outputDir = Path.Combine(workingDir, "Help"); if (!Directory.Exists(outputDir)) { Directory.CreateDirectory(outputDir); } settings.WorkingDirectory = new BuildDirectoryPath(outputDir); } else { // Create the documentation contents... // The conceptual topics... ConceptualTopics.Create(documenter, options); // The reference topics... ReferenceTopics.Create(documenter, options); // The local reference topics... //LocalReferenceTopics.Create(documenter, options); // Create custom TOC, if necessary... TestTocOptions.Create(documenter, options); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } if (documentFile == null) { documentFile = new BuildFilePath(Path.Combine( workingDir, "Documentation" + BuildFileExts.DocumentExt)); } try { if (!loadIt) { Console.WriteLine("Started: Saving"); IList <BuildGroup> groups = documenter.Groups; if (groups != null && groups.Count != 0) { for (int i = 0; i < groups.Count; i++) { Console.WriteLine("{0}: {1}", i, groups[i].Name); } } documenter.DocumentFile = documentFile; documenter.Save(); //Process.Start(workingDir); documentFile = null; Console.WriteLine("Finished: Saving"); Console.WriteLine(); } } catch (System.Exception ex) { Console.WriteLine(ex.ToString()); } try { if (!loadIt && documentFile != null && documentFile.Exists) { Console.WriteLine(); Console.WriteLine("Started: Loading"); BuildDocumenter testDocumenter = new BuildDocumenter(); testDocumenter.DocumentFile = documentFile; testDocumenter.Load(); IList <BuildGroup> groups = testDocumenter.Groups; if (groups != null && groups.Count != 0) { for (int i = 0; i < groups.Count; i++) { Console.WriteLine("{0}: {1}", i, groups[i].Name); } } Console.WriteLine("Finished: Loading"); Console.WriteLine("Getting Ready to saving again"); System.Threading.Thread.Sleep(20 * 1000); Console.WriteLine("Started: Saving Again"); testDocumenter.Save(); Console.WriteLine("Finished: Saving Again"); } //Process.Start(workingDir); } catch (System.Exception ex) { Console.WriteLine(ex.ToString()); } if (!loadIt || documenter == null || documenter.IsEmpty) { return; } // If we get this far, the content is created and we will proceed // to build the help... if (useMSBuild) { string projectFile = Path.Combine(workingDir, "ProjectFormat" + BuildFileExts.ProjectExt); if (!File.Exists(projectFile)) { Console.WriteLine("Project file '{0}' not found."); return; } try { ProjectConsoleRunner consoleRunner = new ProjectConsoleRunner(projectFile); consoleRunner.Run(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } else { BuildProject project = null; try { // Create the project, with the documentation data, the type // of system and the type of build... project = new BuildProject(documenter, BuildSystem.Console, BuildType.Testing); // Initialize the project, if successful, build it... project.Initialize(); if (project.IsInitialized) { project.Build(); } else { Console.WriteLine( "Error in reference build initialization."); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { // Finally, un-initialize the project and dispose it... if (project != null) { project.Uninitialize(); project.Dispose(); project = null; } } } }