One of the nice features of nCover is creating coverage trends. These trends can be included in your reports to show how your coverage is changing over time (hopefully always increasing!)

Unit test coverage trend

Over time though these trend files can grow quite large (100Mb+).  After about a year, at the very most, storing this information becomes somewhat meaningless for me and in our particular build environment tends to slow everything down as time goes on. Currently there is no facility to do this directly from nCover 3.x so to address this I’ve created an MSBuild task which truncates the trend files based on the coverage execution date.Because the trend file is basically a SQLite database, you’ll need to include this in the project references (if the using statement doesn’t give the game away).

Easy as that. To call you simply use the following:

<UsingTask TaskName="wwwlicious.MSBuild.TruncateNCoverTrend" AssemblyFile="wwwlicous.MSBuild" />
<wwwlicious.MSBuild.TruncateNCoverTrend TrendFile="your.trend" PreserveMonths="12" />

So far I’ve been using it for a few weeks on our build servers without any issues but as with all code you find on the internet, I offer no guarantees that it won’t somehow go mad, melt your server, shoot all your employees and set the building on fire before finally committing Harakiri in the server room.

always rememeber to backup first, and use at your own risk!