In 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
Be Sociable, Share!