Hi,

I'd like to make the get-public-key-token function available in NAnt functions.

Typical usage would be:
<echo message="${assemblyname::get-public-key-token(assemblyname::get-assembly-name(filename))}"/>
Output:
154fdcb44c4484fc (for NHibernate here)

I use this function for various purposes, including better strong naming / delay signing support, detecting when a new public key has been added to a project (in places where a new policy must be deployed in that case), etc...

Here's the code in form of a <script> tag (sorry no real 'patch' yet...):

    <script language="C#" prefix="helper">
        <imports>
            <import name="System.Reflection" />
        </imports>
        <code>
        <![CDATA[
              [Function("get-public-key-token")]
              public static string GetPublicKeyToken(AssemblyName name)
              {
                StringBuilder result = new StringBuilder();
                foreach (byte b in name.GetPublicKeyToken())
                    result.AppendFormat("{0:x2}",b);
                return result.ToString();
              }
            ]]>
        </code>
    </script>


What do you think ?

kind regards

Thibaut Barrère

--
[blog] http://www.dotnetguru2.org/tbarrere

Reply via email to