in

ljusberg.se

Smöråkning

Sandcastle August CTP Released

The team behind Microsoft Sandcastle released a new CTP of Sandcastle yesterday. A couple of changes have been made to the components that will make the previous version of my MSBuild Script for Sandcastle fail. Therefore, you'll need to download the latest version of the scripts if you want it to work with the August CTP.

New features include:

  • Support for live links to MSDN documentation.
  • Index for CHM-builds.
  • Frontpage for CHM-builds.

Installation instructions are the same as before! And as always, your comments are appreciated!

Published Aug 28 2006, 10:03 AM by anders
Filed under: ,

Comments

 

Don Eddleman said:

Hey, I hada need to drive the output location of the help files via a msbuild property. To do this I needed to update your script and the targets file for sandcastle. Here is the new script to do the mods to the sandcastle.config

' This script replaces some hard-coded paths in the sandcastle.config file

'

Main()

Public Sub Main()

   Dim xmlDoc

   Dim fso

   Dim inFile, outFile, outputPath

   Dim nodeType, sandcastlePath, sandcastleExamplePath

   Dim sharedContentPath, refContentPath

   Dim xmlSourceNode

   Set fso = CreateObject("Scripting.FileSystemObject")

   If WScript.Arguments.Named.Exists("?") Then

       ShowUsage

       WScript.Quit(0)

   End If

   ' Grab arguments    

   nodeType = WScript.Arguments.Named("nodeType")

   sandcastlePath = WScript.Arguments.Named("path")

   sharedContentPath = WScript.Arguments.Named("shared")

   refContentPath = WScript.Arguments.Named("ref")

   inFile = WScript.Arguments.Named("in")

   outFile = WScript.Arguments.Named("out")

   outputPath = WScript.Arguments.Named("output")

   ' Check arguments

   If Not fso.FileExists(inFile) Then

       WScript.StdErr.WriteLine "ERROR: InFile '" + inFile + "' not found."

       ShowUsage

       WScript.Quit(1)

   End If

   ' Set defaults

   If nodeType = "" Then

       nodeType = "comments"

   End If

   If sandcastlePath = "" Then

       sandcastlePath = "C:\Program Files\Sandcastle"

   End If

   If sharedContentPath = "" Then

       sharedContentPath = sandcastlePath + "\Presentation\content\shared_content.xml"

   End If

   If refContentPath = "" Then

       refContentPath = sandcastlePath + "\Presentation\content\reference_content.xml"

   End If

   sandcastleExamplePath = sandcastlePath + "\Examples"

   ' Load original sandcastle.config file    

   Set xmlDoc = CreateObject("MSXML2.DOMDocument")

   xmlDoc.preserveWhiteSpace = true

   xmlDoc.load inFile

   ' Find all nodes that contain ..\..\ and ..\

   Set xmlNodes = xmlDoc.selectNodes("//@assembly|//@file|//@files")

   For Each xmlNode In xmlNodes

       ' Replace with full path to Sandcastle files

       xmlNode.text = Replace(xmlNode.text, "..\..", sandcastlePath)

       xmlNode.text = Replace(xmlNode.text, "..", sandcastleExamplePath)

   Next

   ' Remove all current content paths

   Set xmlNodes = xmlDoc.selectNodes("//component[@type='Microsoft.Ddue.Tools.SharedContentComponent']/content")

   For Each xmlNode in xmlNodes

       xmlNode.parentNode.removeChild xmlNode

   Next

   ' Replace them with new ones

   Set xmlSourceNode = xmlDoc.selectSingleNode("//component[@type='Microsoft.Ddue.Tools.SharedContentComponent']")

   Dim contentNode

   Set contentNode = xmlDoc.createElement("content")

   contentNode.setAttribute "file", sharedContentPath

   xmlSourceNode.appendChild contentNode

   Set contentNode = xmlDoc.createElement("content")

   contentNode.setAttribute "file", refContentPath

   xmlSourceNode.appendChild(contentNode)

   ' Remove save output path node from element so we can add our replacement

   Set xmlNodes = xmlDoc.selectNodes("//component[@type='Microsoft.Ddue.Tools.SaveComponent']/save")

   For Each xmlNode in xmlNodes

       xmlNode.parentNode.removeChild xmlNode

   Next

   ' Replace the save path with the new one

   Set xmlSourceNode = xmlDoc.selectSingleNode("//component[@type='Microsoft.Ddue.Tools.SaveComponent']")

   Set contentNode = xmlDoc.createElement("save")

   contentNode.setAttribute "base", outputPath + "\html"

   contentNode.setAttribute "path", "concat(/html/head/meta[@name='guid']/@content,'.htm')"

   contentNode.setAttribute "indent", "false"

   contentNode.setAttribute "omit-xml-declaration", "true"

   xmlSourceNode.appendChild(contentNode)

   ' Find the parent node for the new data elements

   Set xmlSourceNode = xmlDoc.selectSingleNode("//index[@name='" + nodeType + "']")

   For Each arg in WScript.Arguments.Unnamed

       ' Add new data node

       Dim dataNode

       Set dataNode = xmlDoc.createElement("data")

       dataNode.setAttribute "files", arg

       xmlSourceNode.appendChild(dataNode)

   Next

   If outFile = "" Then

       ' If no outfile was given, StdOut is used    

       WScript.StdOut.Write xmlDoc.xml

   Else

       ' Otherwise, save the file

       xmlDoc.save outFile

   End If

End Sub

Public Sub ShowUsage()

   WScript.StdErr.WriteLine "This script replaces some hard-coded paths in the sandcastle.config file."

   WScript.StdErr.WriteLine "CScript.exe SandcastleConfigurator.vbs /in:""original config"" [/out:""new config""] [/output:""help output path"" [/path:""Sandcastle path""] ""Xml file 1"" ""Xml file 2"" ..."

End Sub

Here is the new sandcastle targets config (I also updated the path to use the new vs2005 sdk for the help2 compiler

<?xml version="1.0" encoding="utf-8"?>

<!--

 Sandcastle .targets file for MSBuild. This version uses the June CTP of Sandcastle, found at

 http://www.microsoft.com/downloads/details.aspx?familyid=E82EA71D-DA89-42EE-A715-696E3A4873B2&displaylang=en

 Author: Anders Ljusberg (http://blog.ljusberg.com)

Updated 9-27-06 Don Eddleman Added correct pathing to help2 compiler for vs2005 and tokenized output dir.

This file and the SandcastleConfigurator.vbs script should be copied to c:\Program Files\MSBuild\Sandcastle

 For instructions, see my blog and/or the sample provided in SandcastleTest.zip

-->

<Project DefaultTargets="Documentation" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

 <!-- Import hard-coded files -->

 <Import Project="Sandcastle.Files.includes" />

 <PropertyGroup>

   <!-- Path to your Sandcastle installation -->

   <SandcastlePath>c:\Program Files\Sandcastle</SandcastlePath>

   <SandcastleBin>$(SandcastlePath)\ProductionTools</SandcastleBin>

   <SandcastleTransforms>$(SandcastlePath)\ProductionTransforms</SandcastleTransforms>

   <SandcastleOutputStructure>$(SandcastlePath)\Presentation</SandcastleOutputStructure>

   <!-- Path to your HTML Help Workshop installation -->

   <HtmlHelpCompilerBin>C:\Program Files\HTML Help Workshop</HtmlHelpCompilerBin>

   <!-- Path to your HTML Help Workshop installation -->

   <HelpCompiler2Bin>C:\Program Files\Visual Studio 2005 SDK\2006.09\VisualStudioIntegration\Archive\HelpIntegration</HelpCompiler2Bin>

   <!--    Vs 2003 should use this path and install vs2003 help sdk

   <HelpCompiler2Bin>C:\Program Files\Microsoft Help 2.0 SDK</HelpCompiler2Bin> -->

   <!-- These properties should be overridden in your MSBuild file -->

   <HelpName Condition="'$(HelpName)'==''">Test</HelpName>

   <ReferenceContentFilePath Condition="'$(ReferenceContentFilePath)'==''">$(SandcastleOutputStructure)\content\reference_content.xml</ReferenceContentFilePath>

   <SharedContentFilePath Condition="'$(SharedContentFilePath)'==''">$(SandcastleOutputStructure)\content\shared_content.xml</SharedContentFilePath>

   <HelpOutputPath Condition="'$(HelpOutputPath)' == ''">Help</HelpOutputPath>

 </PropertyGroup>

 <ItemGroup>

   <OutputDir Include="$(HelpOutputPath)\"/>

   <OutputDir Include="$(HelpOutputPath)\html\"/>

   <OutputDir Include="$(HelpOutputPath)\art\"/>

   <OutputDir Include="$(HelpOutputPath)\scripts\"/>

   <OutputDir Include="$(HelpOutputPath)\styles\"/>

 </ItemGroup>

 <ItemGroup>

   <CopyFrom Include="$(SandcastleOutputStructure)\art\*.*">

     <CopyTo>$(HelpOutputPath)\art\</CopyTo>

   </CopyFrom>

   <CopyFrom Include="$(SandcastleOutputStructure)\scripts\*.*">

     <CopyTo>$(HelpOutputPath)\scripts\</CopyTo>

   </CopyFrom>

   <CopyFrom Include="$(SandcastleOutputStructure)\styles\*.*">

     <CopyTo>$(HelpOutputPath)\styles\</CopyTo>

   </CopyFrom>

 </ItemGroup>

 <!-- Compiles documentation using Sandcastle, Html Help Compiler AND Microsoft Help Compiler 2.0 -->

 <Target Name="DocumentationAll" DependsOnTargets="CompileCHM;CompileHX">

 </Target>

 <!-- Compiles documentation using Sandcastle and the Html Help Compiler -->

 <Target Name="Documentation" DependsOnTargets="CompileCHM">

 </Target>

 <!-- Compiles documentation using Sandcastle and Microsoft Help Compiler 2.0 -->

 <Target Name="DocumentationHelp2" DependsOnTargets="CompileHX">

 </Target>

 <!-- Creates the default help file output structure -->

 <Target Name="EmptyOutputStructure">

   <MakeDir Directories="@(OutputDir)" />

   <Copy SourceFiles="@(CopyFrom)" DestinationFolder="%(CopyTo)" />

 </Target>

 <!-- Build reflection output-->

 <Target Name="ReflectionXML">

   <!-- Run MRefBuilder -->

   <Exec Command="&quot;$(SandcastleBin)\MRefBuilder&quot; &quot;@(Assemblies, '&quot; &quot;')&quot; /dep:&quot;@(Dependencies, '&quot; /dep:&quot;')&quot; /out:reflection.org"/>

   <!-- Add some more data -->

   <!--<Exec Command="&quot;$(SandcastleBin)\XslTransform&quot; /xsl:&quot;$(SandcastleTransforms)\AddOverloads.xsl&quot; /xsl:&quot;$(SandcastleTransforms)\AddRoot.xsl&quot; /xsl:&quot;$(SandcastleTransforms)\AddGuidFilenames.xsl&quot; reflection.org /out:reflection.xml"/>-->

   <Exec Command="&quot;$(SandcastleBin)\XslTransform&quot; /xsl:&quot;$(SandcastleTransforms)\AddOverloads.xsl&quot; /xsl:&quot;$(SandcastleTransforms)\AddGuidFilenames.xsl&quot; reflection.org /out:reflection.xml"/>

 </Target>

 <!-- Create manifest -->

 <Target Name="ManifestXML" DependsOnTargets="ReflectionXML">

   <Exec Command="&quot;$(SandcastleBin)\XslTransform&quot; /xsl:&quot;$(SandcastleTransforms)\ReflectionToManifest.xsl&quot; reflection.xml /out:manifest.xml"/>

 </Target>

 <!-- Create a sandcastle.config that is modified to fit this project -->

 <Target Name="CreateSandcastleConfig">

 <Exec Command="WScript.exe &quot;$(MSBuildExtensionsPath)\Sandcastle\SandcastleConfigurator.vbs&quot; /in:&quot;$(SandcastleOutputStructure)\Configuration\sandcastle.config&quot; /out:sandcastle.config /ref:&quot;$(ReferenceContentFilePath)&quot; /shared:&quot;$(SharedContentFilePath)&quot; /output:&quot;$(HelpOutputPath)&quot; /path:&quot;$(SandcastlePath)&quot; &quot;@(DocFiles, '&quot; &quot;')&quot;" />

 </Target>

 <!-- Build .htm files -->

 <Target Name="BuildHTM" DependsOnTargets="ReflectionXML;ManifestXML;EmptyOutputStructure;CreateSandcastleConfig">

   <Exec Command="&quot;$(SandcastleBin)\BuildAssembler&quot; /config:sandcastle.config manifest.xml"/>

 </Target>

 <!-- Generate HTML Help 1.x TOC -->

 <Target Name="GenerateHHTOC" DependsOnTargets="ReflectionXML;BuildHTM;EmptyOutputStructure">

   <Exec Command="&quot;$(SandcastleBin)\XslTransform&quot; /xsl:&quot;$(SandcastleTransforms)\ReflectionToChmContents.xsl&quot; reflection.xml /arg:html=$(HelpOutputPath)\html /out:$(HelpOutputPath)\$(HelpName).hhc"/>

   <Exec Command="&quot;$(SandcastleBin)\XslTransform&quot; /xsl:&quot;$(SandcastleTransforms)\ReflectionToChmIndex.xsl&quot; reflection.xml /arg:html=$(HelpOutputPath)\html /out:$(HelpOutputPath)\$(HelpName).hhk"/>

   <Exec Command="&quot;$(SandcastleBin)\XslTransform&quot; /xsl:&quot;$(SandcastleTransforms)\ReflectionToChmProject.xsl&quot; reflection.xml /arg:html=$(HelpOutputPath)\html /out:$(HelpOutputPath)\$(HelpName).hhp /arg:project=$(HelpName)"/>

 </Target>

 <!-- Compile the final HTML Help 1.x CHM file -->

 <Target Name="CompileCHM" DependsOnTargets="GenerateHHTOC;BuildHTM">

   <Exec Command="&quot;$(HtmlHelpCompilerBin)\hhc&quot; $(HelpName).hhp" WorkingDirectory="$(HelpOutputPath)\" IgnoreExitCode="true" />

 </Target>

 <!-- Generate Help Compiler 2.0 TOC-->

 <Target Name="GenerateHCTOC" DependsOnTargets="ReflectionXML;BuildHTM">

   <Exec Command="&quot;$(SandcastleBin)\XslTransform&quot; /xsl:&quot;$(SandcastleTransforms)\ReflectionToHxSContents.xsl&quot; reflection.xml /arg:html=$(HelpOutputPath)\html /out:$(HelpOutputPath)\$(HelpName).HxT"/>

 </Target>

 <!-- Create the Help Compiler 2.0 project files -->

 <Target Name="CreateHXFiles" DependsOnTargets="EmptyOutputStructure">

   <WriteLinesToFile File="$(HelpOutputPath)\$(HelpName).hxc" Lines="$(HXCFileContents)" Overwrite="true"/>

   <WriteLinesToFile File="$(HelpOutputPath)\$(HelpName).hxf" Lines="$(HXFFileContents)" Overwrite="true"/>

   <WriteLinesToFile File="$(HelpOutputPath)\$(HelpName)_a.hxk" Lines="$(HXK_AFileContents)" Overwrite="true"/>

   <WriteLinesToFile File="$(HelpOutputPath)\$(HelpName)_b.hxk" Lines="$(HXK_BFileContents)" Overwrite="true"/>

   <WriteLinesToFile File="$(HelpOutputPath)\$(HelpName)_f.hxk" Lines="$(HXK_FFileContents)" Overwrite="true"/>

   <WriteLinesToFile File="$(HelpOutputPath)\$(HelpName)_k.hxk" Lines="$(HXK_KFileContents)" Overwrite="true"/>

   <WriteLinesToFile File="$(HelpOutputPath)\$(HelpName)_n.hxk" Lines="$(HXK_NFileContents)" Overwrite="true"/>

   <WriteLinesToFile File="$(HelpOutputPath)\$(HelpName)_s.hxk" Lines="$(HXK_SFileContents)" Overwrite="true"/>

 </Target>

 <!-- Compile the final Help Compiler 2.0 files -->

 <Target Name="CompileHX" DependsOnTargets="GenerateHCTOC;BuildHTM;CreateHXFiles">

   <Exec Command="&quot;$(HelpCompiler2Bin)\hxcomp&quot; -p $(HelpName).hxc -l $(HelpName).log" WorkingDirectory="$(HelpOutputPath)\" />

 </Target>

</Project>

Finally, in an msbuild you just need to override the output path via a property:

<HelpOutputPath>help</HelpOutputPath>

Feel free to make available to all.

Cheers,

Don Eddleman

September 28, 2006 5:16 PM
 

anders said:

Thanks Don! I'll incorporate these changes in the next version!

/Anders

September 29, 2006 9:09 AM
 

Sebastian said:

How i can generate only htm docs? i need for making documentation available online for my open source projects

September 29, 2006 4:28 PM
 

Ola Petersson said:

I am getting invalid image links when generating CHM documentation.

This is the end sequence of what I what I see when i select properties of a not working image link:

MyPath\helpname.chm::/html/..\art\collapse_all.gif

This is the end sequence of what I see when i select properties of a not working image link:

MyPath\helpname.chm::/art/pubclass.gif

I do use the September CTP release of SandCastle and had to fix a few small things from your August build scripts (file structure under SandCastle\Presentation was changed). Do you think it is related to this version difference?

Other ideas?

/Ola

October 5, 2006 2:10 PM
 

Ola Petersson said:

Sorry about the error in my previous comment. This is a WORKING image link:

MyPath\helpname.chm::/art/pubclass.gif

October 5, 2006 2:11 PM
 

anders said:

I'm afraid I haven't had a chance to upgrade the scripts to the September CTP yet. I'll try to get around to that in the next couple of days. It sounds quite likely that that is the problem here..

October 5, 2006 2:13 PM

Leave a Comment

(required)  
(optional)
(required)  
Add
Powered by Community Server (Non-Commercial Edition), by Telligent Systems