Get PublicKeyToken of an assembly reference from within Visual Studio

Situation

You need the public key token of an assembly reference. E.g. to set the InternalsVisibleTo() attribute for a Unit-Test.

Problem

There is no standard mechanism embedded in Visual Studio (2010).

Solution

Create a “external tool” entry that calls sn.exe and redirects the output to the output window.

Dialog: [Tools] – [External tools…] – [Add]

Title: As you wish (e.g. “Get &PublicKeyToken).

Command: C:Program FilesMicrosoft SDKsWindowsv6.0ABinsn.exe

Arguments: -Tp $(TargetPath)

Use Output window: Check

Sources

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.