I have often needed to get the Public Key Token of a strong named assembly and have always done it by hand using sn.exe or the folder method. So the issue is how to get the Public Key Token easily - particularly when you need to create a Safe Control or otherwise add it to the web.config file. Of course, you can always build it, deploy to the GAC and find it in the c:\Windows\Microsoft.net\assembly folder under the appropriate folder:
GAC_64 = 64 bit
GAC_MSIL = Any CPU
You'll find it there and the Public Key Token is part of the folder name. However, this is a pain - so this method turned out to work outstandingly well.
Step 1 - Find where sn.exe resides - where it is depends on which version of Visual Studio you are running. Open the Developer Command Window and type in:
In my case, it found it under c:\Program Files (x86)\Microsoft SDKs\Windows\v10.0a\bin\NETFX 4.6.1 Tools\sn.exe:
Step 2 - Open Visual Studio, click Tools in the tool bar then select External Tools. When the pop up opens, click Add. Set the Title, Command and Arguments:
Title = Get SN Token
Command = c:\Program Files (x86)\Microsoft SDKs\Windows\v10.0a\bin\NETFX 4.6.1 Tools\sn.exe (the path to sn.exe)
Arguments = -T $(TargetPath)
Next, click the Checkbox to Use Output Window
This looks like this:
Click OK to save it.
Step 3 - Get the Public Key Token. When the project is opened (and you've built it at least once), just click Tools in the tool bar and select Get SN Token - this opens the output window as shown:
Jeremiah's original post