Sharing public key across multiple AssemblyInfo

565 views Asked by At

I have signed all my assemblies with strong name.

Now I have to allow all internal assemblies that are friends with unit tests to share the publickey info. This can be done using,

[assembly: InternalsVisibleTo( "MyProject.UnitTests, PublicKey=XXXXXXXXXXXXXXXXXXXXXX" )]

I am re-using the same public key across all projects.

I have a global CommonAssemblyInfo.cs that is linked to all projects and each project apart from referring to CommonAssemblyInfo.cs refers to a local one "AssemblyInfo.cs" as well.

I want to keep the public key value in CommonAssemblyInfo.cs and reuse the same value in all Local "AssemblyInfo.cs" to be used in "InternalsVisibleTo" attribute to reduce duplication and improve maintainability.Is there any way to do this?

One option is that I can place the public key in a static common class and reuse them from all AssemblyInfo.cs but, this needs an additional reference to the common project.

1

There are 1 answers

0
Lokesh On

You can use some placeholder for public key inside the assembly attribute in CommomAssemblyinfo.cs file and that can be replaced using python script(I prefer that) or some other tool while creating installer.

Please refer to the link to know more how to replace placeholders in python script.