Filter Files based on TeamCity Checkout Dir

Filter Files based on TeamCity Checkout Dir

We have NCover v3.4.16.6924 integrated with TeamCity v6.02 using NUnit and MSTest. We successfully get reports, but they are including more code than we want.

Specifically, we only want to include source code files for the solution we are building and do not want dependency code included. In our CI setup, we have two high performance machines with multiple build agents on each.

I have tried to use //onlywithsource flag, but since there is a high chance referenced dependencies were built on the same machine, we get a lot of external dependency code included in the reports since NCover is able to find the source on the machine. This causes our coverage number to be way off since the target solution is not attempting to test this dependency code.

A way I have gotten around this is to use the //eas flag with a lot of RegExps, but this is very cumbersome, easily prone to error, and requires a lot of manual work and maintenance to keep accurate for our 60 or so builds, especially if dependencies change.

A solution I was thinking of was to only use source code files that are available in the checkout directory. This is easily accessible through the %system.teamcity.build.checkoutDir% configuration parameter. The problem is that the directory provide is not properly escaped for a Reqular Expression. \Q...\E is commonly implemented literal string in Regular Expressions and I tried to use it:

//if "\Q%system.teamcity.build.checkoutDir%\E.*"

but I get the following error:

[11:09:20]: [Step 2/3] NCover Complete v3.4.16.6924 x64 (Administrator)
[11:09:20]: [Step 2/3] Copyright (c) 2007 - 2010 Gnoso Inc.
[11:09:20]: [Step 2/3] License Key: XXXXXXXXXXXXX
[11:09:20]: [Step 2/3] Registered to Customer #: 3850 for 3 Machines
[11:09:20]: [Step 2/3] NCover has determined that one of the paths in the
[11:09:20]: [Step 2/3] //h or //w commands ends with a backslash (\).
[11:09:20]: [Step 2/3] Please remove or escape the backslash and run NCover again.
[11:09:20]: [Step 2/3] Process exited with code 20000

I am not even setting //h or //w.

Is there a way to pass in a literal directory filter? Or is there another way to achieve my goal of only covering code that is in the target solution?


RE: Filter Files based on TeamCity Checkout Dir

smeat32,

The error you're seeing is typically confined to bitness problems--that is, when your NCover bit level does not match the tested application bit level. Can you tell me a little detail about this setup?

Also, using the //eas should work for you. I don't think this is an issue with regexes.