views:

85

answers:

1

We have a C# solution with ca. 55 projects, including test projects.

Since part of the project is sharepoint all dll's are signed.

We would like to run unit tests with code coverage. We then get the problem the code coverage cannot instrument signed dll's.

We therefore need to unsign the dll's, run the tests, and then resign them. With the large number of project files this is cumbersome.

Question is: Is it possible to automate this in any way? (To resign I can just do an undo checkout)

+1  A: 

Yep, that's easy. The key signing setting is stored in the project file, which is just XML. Write the script to traverse this file and remove the setting for the signing.

  1. Remove XML setting in the .csproj file that defines the signing
  2. Rebuild the project(s) using msbuild
  3. Run your unit tests against these rebuilt DLL's.
  4. Traverse the .proj file again and add the setting back in.
  5. Recompile using the signing.

In the .csproj file, you're looking for the following two lines to remove:

<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>MyKey.snk</AssemblyOriginatorKeyFile>
The Matt