Multiple projects need to use 1 SNK file
Asked Answered
K

3

13

I'm using Visual Studio 2008 and I have a solution which contains multiple projects. I have 1 snk to sign my assemblies and this lives in a solution folder.

I've linked the snk to each of my projects but now when I attempt to sign my project with that linked snk I can't find the snk file with the file dialog.

Have I missed a step here?

Solution
   > Solution Folder
       MyKey.snk
   > Project X
       > _LinkedFiles
           MyKey.snk (physical file doesn't appear here but shows in VS)
       > ...
Kingsbury answered 12/2, 2010 at 14:17 Comment(0)
K
2

Well, not much response here but I did find a solution I was comfortable with. I've got a ProductAssemblyInfo which lives in a solution folder but is linked to each project as below.

Solution
   > Build (Solution Folder)
       MyKey.snk
       ProductAssemblyInfo.cs
   > Project X
       > _LinkedFiles
           ProductAssemblyInfo.cs
       > ...

The ProductLevelAssembly contains the following line:

[assembly: AssemblyKeyFile("../../Build/MyKey.snk")]

That way the key file never gets copied into each project but each assembly is still signed by the key.

Kingsbury answered 20/2, 2010 at 7:47 Comment(2)
AssemblyKeyFile is deprecatedUprush
deprecated? source?Izabel
U
15

Sharing a Strong Name Key File Across Projects:

http://blogs.msdn.com/shawnfa/archive/2006/04/24/582278.aspx

Uprush answered 23/3, 2010 at 13:58 Comment(1)
link is dead. please provide more content.Fritzie
K
2

Well, not much response here but I did find a solution I was comfortable with. I've got a ProductAssemblyInfo which lives in a solution folder but is linked to each project as below.

Solution
   > Build (Solution Folder)
       MyKey.snk
       ProductAssemblyInfo.cs
   > Project X
       > _LinkedFiles
           ProductAssemblyInfo.cs
       > ...

The ProductLevelAssembly contains the following line:

[assembly: AssemblyKeyFile("../../Build/MyKey.snk")]

That way the key file never gets copied into each project but each assembly is still signed by the key.

Kingsbury answered 20/2, 2010 at 7:47 Comment(2)
AssemblyKeyFile is deprecatedUprush
deprecated? source?Izabel
S
0

Don't link it, just make copies of it. If you rebuild the SNK, you will need to copy it to all the projects again, but the likelihood of needing to do that is VERY low. In fact, we only change SNKs when modifying major version numbers.

Also when you link a file, you are linking it in the solution file, not making a copy which edits both places at once. The browse dialog is only going to show you files which exist on the drive.

Stodgy answered 12/2, 2010 at 14:25 Comment(1)
This answer will technically work. But remember, your PRIVATE key file (.snk) is like the thing that says "We are who we say we are"......thus having copies of it could be a security risk. So I agree with the answer, but it comes with a disclaimer (IMHO).Expostulate

© 2022 - 2024 — McMap. All rights reserved.