OpenCover does not cover under TeamCity

opencover, teamcity

Solution

Preregister OpenCover.Profiler.dll using regsvr32 manually. But to execute this you should run cmd with admin rights.

Problem

I have a project that does NOT give me any coverage in the output coverage file when running under TeamCity. When I run from the command line it covers fine. Apparently there is some permission problem with the local system account that is used when TeamCity runs, ie if I change the TeamCity runner to use one of the logins I use to accesss the machine it gives coverage. However I don't want to maintain the password of that user in the TeamCity service. I'm using the -register:user param when kicking OpenCover off in the nant script, that doesn't help. What is the recommended setup to get the coverage working when running under TeamCity ?

Original source