Trim an assembly's build version number

Jan 3 at 4: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?

Thanks!

Ken
Editor
Jan 3 at 5: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:
<parameter>
    <xsl:variable name="versionParts">
        <xsl:call-template name="tokenize">
            <xsl:with-param name="string" select="$library/assemblydata/@version" />
        </xsl:call-template>
    </xsl:variable>
    <xsl:variable name="versionNodes" select="msxsl:node-set($versionParts)" />
    <xsl:value-of select="concat($versionNodes/token[1], '.', $versionNodes/token[2])" />
</parameter>
Also add the following template to the file:
<xsl:template name="tokenize">
    <xsl:param name="string"/>
    <xsl:param name="separator" select="'.'"/>

    <xsl:choose>
        <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)"/>
            </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
            <token><xsl:value-of select="$string"/></token>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>
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.

Eric
Jan 4 at 4:31 AM
Thanks Eric!

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

Ken
Editor
Jan 12 at 1: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.

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