Get PublicKeyToken using external tools

I hate fishing around to get the publickeytoken for my strong named assemblies, so I fished around for a way to do it in Visual Studio. Here's what I did:

  1. Create a new External Tool - I called mine Get PublicKeyToken
  2. Map to the sn.exe file in the Windows SDK <DRIVE:\>Program Files\Microsoft SDKs\Windows\v6.0A\Bin\sn.exe
  3. Add the command you want to execute, in this case, it's -T $(TargetPath) - you can get the TargetPath monniker from the flyout.
  4. Check the Use Output window checkbox.

Get PublicKeyToken

Now, to execute it, select a *.dll file. You can select the file in the bin directory of your dev project, go to Tools->Get PublicKeyToken and the output will be rendered to the Output window.

Comments

  • Anonymous
    July 16, 2008
    I wrote a utility a while ago that can be called from the external tools function to do this. It can figure out the public key info from binaries and snk files. http://neovolve.com/archive/2007/12/06/getpublickey-internalsvisibleto.aspx I also find it helpful to be able to right-click on a file in solution explorer and click Open With, then select this utility.

  • Anonymous
    July 16, 2008
    Very nice!