Three Is It

Because two isn't enough and four is just too many

America does not go abroad in search of monsters to destroy.
President John Quincy Adams
Home Blogs Genealogy Brad's Bookshelf Subscriptions Contact Sign in
 

About the author

Brad Butts is a .NET developer and architect. He is married with children and enjoys reading, working out, and genealogy is his five minutes of spare time.
E-mail me Send mail
National Debt Clock

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Sidebar - signing assemblies

As a sidebar to my post on fully-qualified assembly names, I wanted to post the steps I use to sign an assembly.  These steps have changed from what I used to do in .NET 1.1, where I used an assembly annotation in AssemblyInfo.cs to point to the key file.  That attribute has been deprecated in .NET 2.0.

I sign an assembly by creating an SNK file with the SN.exe utility.

  1. At the command line, execute sn -k BradTestKey.snk
  2. Import the key pair into the machine container by executing, sn -i BradTestKey BradTestKey.snk
  3. Open the CSPROJ file in Notepad
  4. Under the first <PropertyGroup> node, add <KeyContainerName>BradTestKey</KeyContainerName>


Now, your assembly is signed. 

But wait a minute, what if I only want to sign my Release builds, not my Debug builds.  Can I do that?  Why yes, you can.  A default CSPROJ file will contain MSBuild PropertyGroup nodes that execute either under the Debug or Release configuration mode.  So, here's what you do:

  1. Open your CSPROJ file in Notepad
  2. Find the <PropertyGroup> that looks like this: <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
  3. Under that node, add <KeyContainerName>BradTestKey</KeyContainerName>


Now, only your Release binaries will be signed.

Remember that the BradTestKey.snk and the BradTestKey machine container name are my conventions and you should use your own. 

Proof that is worked (test code is also attached to this post):

ConfigFullDNTests.zip (25.66 kb)

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:
Categories: Technology Blog
Posted by Brad on Sunday, July 20, 2008 7:43 AM
Permalink | Comments (0) | Post RSSRSS comment feed

Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

Thursday, August 21, 2008 7:17 AM