Asp.net, listbox, htc, behavior, autosearch listbox
Welcome to MSDN Blogs Sign in | Join | Help

Get Public Key Token from Snk File using Msbuild

I have written a small msbuild script which can be used to get the public key and the public key token from the .snk file.

This attachment needs to be executed from the visual studio command prompt . Update the WorkingDir and SnkFilePath as needed, after downloading  the attachment.

Run it as msbuild <file name>. the output token is in Onlytoken.txt.

The output public key is in OnlyPublic.snk.

Here is the snippet of the same script.

<Project DefaultTargets="GetPublicKey" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>

<WorkingDir>D:\Work\</WorkingDir>

<HighLevelErrFile>ErrLog.log</HighLevelErrFile>

<SnkFilePath>StrongNameKey.Snk</SnkFilePath>

</PropertyGroup>

<!--TFS Get Latest Configs-->

<Target Name="GetPublicKey">

<WriteLinesToFile File="$(HighLevelErrFile)" Lines=" ============= Operation Started =============" Overwrite="True"/>

<Exec Command ="sn -p $(SnkFilePath) OnlyPublic.snk" WorkingDirectory ="$(WorkingDir)" />

<Message Text ="Retrieved Public key from snk file and written to OnlyToken.snk"></Message>

<Exec Command ="sn -t OnlyPublic.snk > OnlyToken.txt" WorkingDirectory ="$(WorkingDir)" />

<Message Text ="Done Retrieved Public key token from snk file and written to OnlyToken.txt"></Message>

<WriteLinesToFile File="$(HighLevelErrFile)" Lines="Done Retrieved Public key token from snk file" Overwrite="false"/>

</Target>

</Project>

 

 

Published Tuesday, June 23, 2009 8:24 PM by Sundara Prabu .T
Filed under: , ,

Attachment(s): GetPublicSnk.msbuild

Comments

No Comments
Anonymous comments are disabled
 
Page view tracker