in

Platinum Bay

Peace, Love, Team System, and Community

This Blog

Syndication


.NETicated

Using a Single Strong Name Key across Multiple Projects

When strongly naming project, the Visual Studio default behavior is to copy the source key file into each and every individual project. This might not be ideal in all cases as you may want to be able to change strong name keys across all the projects at a future time.

Fortunately, there is a workaround using the linked files trick.

First, create your *.snk file in the solution directory. If the project is under source control, be sure to add the *.snk file as a solution file to the solution node in Visual Studio. You can do this by right-clicking on the solution node in the Solution Explorer tool window, choosing "Add Existing Item…" and selecting the *.snk file.

Then, in each project you wish to sign, right-click on the project node and choose Add > "Existing Item…" Browse to and select your *.snk file, but here's the twist. Instead of just clicking Add, use the dropdown arrow on the right side of the Add button and select Add as Link. This adds a reference to the original file location without copying it locally. At compile time, linked files are treated as local (to the project) files.

Finally, right-click on the project and choose Properties. Navigate to the Signing tab, check the "Sign the assembly" checkbox, and from the dropdown list, select the fully-qualified name (FQN) that is displayed. Then type Ctrl+Shift+S (Save All) to save. The important thing to remember here is that even though the FQN was displayed in the dropdown, a relative path is stored in the *.*proj file.

If you would like to validate that the relative path is stored, you can right-click on the project node, choose "Unload Project", right-click again, and choose Edit… In the first PropertyGroup, there is a node named AssemblyOriginatorKeyFile. You will see it is set to a relative path.

Hope this helps

Published Jul 10 2008, 08:51 AM by Steve
Filed under:

Comments

July 11, 2008 12:28 AM

Link Listing - July 10, 2008

 

July 11, 2008 12:28 AM

ASP.NET Static Singletons for ASP.NET Controls [Via: Rick Strahl ] WPF Learning WPF with BabySmash...

 

July 30, 2008 12:15 AM

Link Listing - Monday, July 21, 2008

 

December 24, 2008 1:20 AM

Very nice tip. In case you are sensetive about keeping single copy of single resource this article is a perfect help. I was looking for the same problem and trick mentioned above worked for me.

Thanx dude.

Asif
 

July 22, 2009 6:52 AM

Its also helpful for GlobalAssemblyInfo.cs file too.

Anonim
 

August 31, 2009 4:21 AM

Thanks.

Albert
 

Leave a Comment

(required )  
(optional )
(required )  
Add

About Steve

Steve Andrews is a Team System MVP and INETA Speaker, and has been working as a developer for more than 9 years. During this time, he has designed and developed applications in such widely varying areas as trust accounting, medical information management, supply chain management, and retail systems. Steve is also an MCP, ICSOO, Speaker Liaison for the Philly .NET User Group, and community fanatic.
Powered by Community Server (Commercial Edition), by Telligent Systems
© Platinum Bay | Some Rights Reserved Creative Commons License

Disclaimer: The information in this weblog is provided "AS IS" with no warranties, and confers no rights. This weblog does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion. Feel free to challenge me, disagree with me, or tell me I'm completely nuts in the comments section of each blog entry, but I reserve the right to delete any comment for any reason whatsoever (abusive, profane, rude, or annonymous comments) - so keep it polite, please.