Trim an assembly's build version number

Jan 3, 2014 at 5:38 AM
I'm doing API documentation. Sandcastle's assembly reflection is a little more detailed than I want. the Assembly reference display looks like:

Version: 2.0.5115.30869

I'd like to trim it down to just:

Version: 2.0

Where would I look to configure that?


Jan 3, 2014 at 6:26 PM
You'll need to modify the XSL transformation file utilities_reference.xsl to do that. Find the template "assemblyNameAndModule" (it may vary depending on which presentation style you use) and change the last parameter to this:
    <xsl:variable name="versionParts">
        <xsl:call-template name="tokenize">
            <xsl:with-param name="string" select="$library/assemblydata/@version" />
    <xsl:variable name="versionNodes" select="msxsl:node-set($versionParts)" />
    <xsl:value-of select="concat($versionNodes/token[1], '.', $versionNodes/token[2])" />
Also add the following template to the file:
<xsl:template name="tokenize">
    <xsl:param name="string"/>
    <xsl:param name="separator" select="'.'"/>

        <xsl:when test="contains($string, $separator)">
            <token><xsl:value-of select="substring-before($string, $separator)"/></token>
            <xsl:call-template name="tokenize">
                <xsl:with-param name="string" select="substring-after($string, $separator)"/>
            <token><xsl:value-of select="$string"/></token>
I can add a new XSL transform parameter to customize the number of parts shown and expose it on the Transform Args property page for a future version.

Please note that this project has been discontinued and may not be monitored as frequently. For future questions or issues concerning Sandcastle or SHFB, post them over on the Sandcastle Help File Builder project's discussion page. Thanks.

Jan 4, 2014 at 5:31 AM
Thanks Eric!

You really are generous with your time and a great community guy.

Jan 12, 2014 at 2:44 AM
Just to let you know, I've made the change as described. In the next release, a new parameter is exposed in the Transform Args property category call maxVersionParts. It can be set to 2, 3, or 4 to show just that many parts. If set to any other value or left blank, it shows the entire version number including the assembly file version if present which appears in parentheses after the assembly version number which was the prior behavior.

Marked as answer by kjopc on 1/21/2014 at 5:04 PM