Sandcastle and Powershell

We have been using Sandcastle and the Sandcastle help file builder tools for our code documentation for quite some time now. One thing kept bugging me, the fact I had to edit the shfbproj file everytime we added or removed a project to the solution.

Since we use powershell over at the build server to do extra tasks around building and packageging, I wrote a little powershell script to generate (part of) the shfbproj file.

First we need to modify the shfbproj file to include a reference to an environment variable were we will store the assemblies to generate documentation for:


The thing to note here is the $(DOCUMENTSOURCES) which is going to be replaced with the content of environment variable DOCUMENTSOURCES by MsBuild.

Next we will generate this $(DOCUMENTSOURCES) through our powershell, which will put a piece of XML in this variable which contains all the documentsources:

foreach ($folder in get-Childitem | where {$_.PsIsContainer}) {
    cd $
    if (Test-Path "manifest.ddf" ) {
        cd bin
        $dll = $
        $dll += ".dll"
        $xml = $
        $xml+= ".xml"
        if (Test-Path $dll ){
            $documentsources += "<DocumentationSource sourceFile=""..\"
            $documentsources += $
            $documentsources += "\bin\"
            $documentsources += $dll
            $documentsources += """ />"
        if (Test-Path $xml ){
            $documentsources += "<DocumentationSource sourceFile=""..\"
            $documentsources += $
            $documentsources += "\bin\"
            $documentsources += $xml
            $documentsources += """ />"
        cd ..   
    cd ..
cd $deploymentpath
$env:documentsources = $documentsources

And now all projects ( in this case that have a manifest.ddf ( SP2007 ) ) will be used for generating the documentation.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: