when I use the -register option in Opencover I get a unhandled exception
C:\hudson\jobs\SPIN.Accounts.AccountNode\workspace>"C:\Program Files (x86)\OpenCover\OpenCover.Console.exe" -target:"C:\Program Files (x86)\NUnit 2.5.10\bin\net-2.0\nunit-console.exe" -targetargs:"/noshadow mydll.dll" -output:"coverage-result.xml" -filter:"+[myNamespace]*" -register:user
An exception occured: Object reference not set to an instance of an object.
stack: at OpenCover.Framework.ProfilerRegistration.ExecuteRegsvr32(Boolean userRegistration, Boolean register, Boolean is64)
at OpenCover.Framework.ProfilerRegistration.ExecuteRegsvr32(Boolean userRegistration, Boolean register)
at OpenCover.Console.Program.Main(String[] args)
I've tried -register and -register:user and both give me the same error. This only happens when I run the it in Jenkins.
So can some one explain what is the significance of the -register parameter and also how can I can get this to work in Jenkins? Thanks.
Update: I am not sure why the -register parameter didn't work in Jenkins but I ended up registering the profilers outside of Jenkins and it works now. Not ideal but at least there's a work around. Would still like to find a proper solution to this though. I'm not sure if anybody else has this problem but maybe it's worth a little wiki entry on GitHub.
Is jenkins running under a service account?
If so does it have permission to register a COM object?
The -register:user option is for accounts that don't have permissions to register a service for all users however AFAIK this won't work when running as a service.
Registering the profilers under an account with the correct permissions is the correct way to go and is the same for other CI systems such as TeamCity.