NCover Documentation

NCover Prune

Warning: There is no undo for the NCover Prune command. Please make a backup of your NCoverdata folder before using this command.

The Prune command was created as a tool to shrink the data store by removing unwanted coverage modules, namespaces, classes, or methods.

The most general use case is to globally delete modules that add no value to the coverage statistics. An example is the "XML.Serializer" modules generated for any assembly with serializable content.

Verify Data to be Pruned

The Prune command can remove a lot of unnecessary data, but it can also remove important data just as easily. It is imperative to verify which modules will be affected before removing any data.

Since the Prune command will not execute until the --force option is specified, you can test possible prune operations before actual execution.

Again, there is no undo for the Prune command so make a backup of the data store before you begin this operation.

To start, you can get a list of all modules in all NCover projects with the following command:

ncover prune --global --module=.*

The above command will list all modules in the system. NEVER use it in conjunction with --force or all coverage data will be deleted.

Note: All options for the Prune matching variables are matched by Regex.

Options for Removing Data

Once you've identified modules that are not useful, the Prune command with the --global option will remove the modules from all projects, and re-aggregate affected executions.

It's best to prune all the modules in a single command so aggregation is triggered only once.

Sample Prune regex:

ncover prune --global --module=(xml.serializers.dll|.UnitTests.dll|.DAO.dll) --force

This command will remove all modules that match any of the three patterns provided. General Regex patterns apply for special characters, line ending/beginning, etc.

The same pruning operations can be performed by namespace, class, and even method. Regex patterns make this command very flexible, but it is imperative to test the outcome before updating.

The project option of the command will limit the command, when possible, to the scope of a given project. Pruning from a single project does not release as much space, because static data about assemblies is global to all projects and will not be pruned unless the global option is used.

After pruning coverage from the data store, space can be reclaimed by using the NCover Compact command.

If you are pruning a large number of modules, it is a best practice to disable aggregation on all projects.

When pruning operations are completed, re-enable aggregation and use the NCover Aggregate command to update only the projects and executions of interest.

If you still need technical assistance, we can help:

Submit A Support Ticket