brutaldev / StrongNameSigner

Strong-name sign third party .NET assemblies without the source code.
https://brutaldev.com/post/net-assembly-strong-name-signer
Other
327 stars 68 forks source link

Friend assembly references are not updated with new keys. #28

Closed loicmorvan closed 7 years ago

loicmorvan commented 7 years ago

As you may know, when declaring a friend assembly with the attribute InternalsVisibleTo, the public key of the friend assembly must be provided.

When signing assemblies with StrongNameSigner, the tool updates references very well, except these InternalsVisibleTo which then reference unsigned versions of the friend assemblies.

This leads to errors at loading.

Can you make the tool manage these cases? Thanks!

brutaldev commented 7 years ago

InternalsVisibleTo are also corrected or removed (since v1.4.4) depending on whether the dependencies can be found. I suspect you are signing separately and not including all the assemblies you want to fix as a group.

Make sure you are using the latest version and providing all the assemblies you want to fix at the same time instead of trying to sign each one individually. If assemblies are left with InternalsVisibleTo pointing to assemblies that are not signed you will get loading errors. Refer to Dealing with Dependencies for how to include all the related assemblies in one batch.

loicmorvan commented 7 years ago

I sign an entire folder with the command line tool and the option '-in'. The version of StrongNameSigner installed is the latest. I will triple check and try to reproduce what I said in order to give material.

brutaldev commented 7 years ago

For reference, InternalsVisibleTo attributes are updated on line 309 of the signing helper.

I've just re-enabled the unit tests locally for the fix method to include the public key in the attribute and verified it also works by inspecting with Reflector/ILDasm. The test assemblies have attribute stubs to verify this quite easily already.

If you can produce a sample project where you believe the fixes are not being applied correctly I can help debug it.