The situation is as follows:
[assembly: InternalsVisibleTo("...")]
attribute to the main project AssemblyInfo.cs fileSo, how do I solve this?
If I sign the main project output, and not the test library, and specify only the assembly name in the InternalsVisibleTo
attribute, I get this compile-time error:
Error 1 Friend assembly reference 'Mercurial.Net.Tests' is invalid. Strong-name signed assemblies must specify a public key in their InternalsVisibleTo declarations. C:\Dev\VS.NET\Mercurial.Net\Mercurial.Net\Properties\AssemblyInfo.cs 22 31 Mercurial.Net
So apparently not signing the test project output isn't enough.
Is my only option to remove the settings that sign the projects, and modify the project files as part of my binaries build script? ie. hunt down the <SignAssembly>false</SignAssembly>
element of the project file and modify it, before building?
Is it an option to have an SNK file you release just for testing?
You can then have two InternalsVisibleTo
and switch which one you use with an #if
, e.g.:
#if FOR_RELEASE
[InternalsVisibleTo(... your private SNK ...)]
#else
[InternalsVisibleTo(... test SNK which you release ...)]
#endif
You can then set FOR_RELEASE
when you're creating your builds that you want to publish.
What I did with my OS projects is simple: I have a private SNK that I only use when building the projects for a release. The projects are only signed when I compile for a release and normally the projects don't reference a SNK. This makes it easy to use the InternalsVisibleTo
attribute, because without a SNK this always works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With