Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to unit testing delay-sign assemblies using nunit

Tags:

.net

nunit

We have a project that all assemblies are delay-signed. The development machines are set to skip verification using sn.exe tool :

sn.exe -Vr *,PUBLIC_KEY_TOKEN_HERE

If we test those assemblies using nunit (GUI version), the test won't work (all tests are failed) because of delay-signed. But if those assemblies are re-signed, the test works. We're all know that to re-sign an assembly, we need private public key pair file (e.g. mycompany.snk). We don't think it's a good practice give the mycompany.snk file to all developers.

Is there any solution so that every developer can unit-testing their assemblies without re-resigning or without the need of mycompany.snk file ?

like image 328
Khairuddin Ni'am Avatar asked Apr 26 '11 01:04

Khairuddin Ni'am


1 Answers

Are you by any chance developing on a 64 bit version of Windows? We had a similar issue some time ago, where we were delay-signing assemblies but they were not loading correctly during unit testing. The problem turned out to be because we were developing on 64 bit windows. It turns out that there are two sn.exe programs, one for 32 bit and one for 64 bit. (The 64 bit version is located in a directory "x64" below the bin directory for the 32 bit executable in the windows SDK -- I am not on a development machine at the moment, sorry, so I cannot give you the exact path from memory). What we do is use the "sn -Vr" command using the 32 bit version, and then run the same command using the 64 bit version and everything works.

like image 51
John Jeffery Avatar answered Dec 24 '22 00:12

John Jeffery