Compiling Documentation using NAnt and Sandcastle
August 16th, 2007 by Bert WillemsIn this article I will show you how you can use NAnt and Sandcastle to automatically generate API documentation for your assemblies. Getting Sandcastle to work is a very tricky but fortunately for you I have encapsulated all the necessary steps into one single build file. In this article I will explain how you can use my build script. I assume that you have some knowledge of NAnt and know how to write NAnt build scripts.
If you do not have Microsoft Sandcastle [1] and Microsoft HTML Help Workshop [2] installed yet, please do so first. I use the June 2007 CTP release of sandcastle which is at the time of writing the latest version. Next you need to download my documentation build script. Make sure the following paths are correct:
<property name="sandcastle.dir" value="c:\Program Files\Sandcastle" /> <property name="sandcastle.hhc.exe" value="c:\Program Files\HTML Help Workshop\hhc.exe" />
Now that you have everything set up take a look at the following sample build script:
<include buildfile="${root.dir}\documentation.build" />
<target name="generate-docs">
<!-- path to the assemblies which should be commented -->
<property name="sandcastle.assemblies.files" value="${build.dir}\MyAssembly.*.dll" />
<!-- path to the comment files -->
<property name="sandcastle.comments.files" value="${build.dir}\comments\*.xml" />
<!-- the directory where all the dependancies are located -->
<property name="sandcastle.libs.dir" value="${build.dir}" />
<!-- the working directory of sandcastle -->
<property name="sandcastle.working.dir" value="${build.dir}\docstmp"/>
<!-- the filename to which the generated documentation file will be copied -->
<property name="sandcastle.output.file" value="${build.dir}\docs\My Assembly Documentation.chm" />
<!-- execute -->
<call target="doc-generate" cascade="false" />
</target>
That is basically it. Configure the properties to your own wish and enjoy your fancy looking documentation.
I hope you find my script useful. I have you have any questions, comments or suggestions please let me know.
Sources
| [1] | Microsoft Sandcastle |
| [2] | Microsoft HTML Help Workshop |

4 Replies to “Compiling Documentation using NAnt and Sandcastle”
April 13th, 2009 at 21:30
Hi Bert,
I had two questions for you. I am trying your example, but I am not clear on what the:
“sandcastle.assemblies.files” value=”,
“sandcastle.assemblies.files” value=”,
“sandcastle.working.dir”,
and “sandcastle.libs.dir”.
This example looks really handy, i just need a one more hand.
Thanks for putting this out there!
-matthew (USA)
April 14th, 2009 at 18:34
Hello Matthew,
I am glad you liked my article, here are the answers to your questions, I hope that they will give you the hand you need.
sandcastle.assemblies.files, the assembly files which to index.
sandcastle.working.dir, the directory in which SandCastle store the files.
sandcastle.libs.dir, the directory where all the dependencies are located
Regards,
Bert
October 19th, 2009 at 02:32
Hi Bert,
I try to following your way, but I have several configuration in it.I did uninstall the sandcastle and change the path of sandcastle.dir and sancastle.hhc.exe to my local folder (in d:).
Unfortunately, it gives me an error. it said , Microsoft.Ddue.Tools.VisualBasicDeclarationSyntaxGenerator cannot found in BuildComponents.dll.
is it takes from the .net framework or not?
thanks in advance,
Vera
October 21st, 2009 at 19:35
This article is very old and for a beta version of this project. I haven’t been following the development of this project, so I honestly can’t give you the answer. Maybe you will have more look here: http://sandcastle.codeplex.com