Take Command Of Your NCover Code Coverage Projects

ncover_take_command_of_ncoverAlthough many users preference the ease and convenience of  exporting, modifying and creating code coverage projects through the NCover GUI, there may be situations when you prefer to directly manage projects from the command line or as part of a scripted process.  In these situation, NCover offers the ability to create projects, import projects and project settings and export projects directly from the command line.

Export A NCover Project From the Command Line

Exporting projects can be useful if you want to make a backup of all your project settings as part of your  normal process or if you want to make a project and all of its settings portable to use on another machine or in a different environment.  In order to export a project, it must first be setup with NCover.

The Export Project command can then be used to export all of the project settings into a JSON file. Here is the usage:

NCover Project-Import --file=<file name> [--project=<project name>]

Here is an example of how you would export an exiting project named “Return Of The Override” to a JSON file:

ncover project-export --file="C:\MyPath\return-of-the-override" --project="Return Of The Override"

Please reference Export Project Settings in the NCover Documentation for additional details.

Import A NCover Project From the Command Line

The Import Project command can be used to modify existing NCover project settings from the command line.  The simplest way to accomplish this is by first using the Export Project command to export the project settings to a JSON file.  You can then directly edit the JSON file and use the Import Project command to update.

If you are updating an existing project’s settings, it is important to note that you must use the –overwrite option, otherwise an entirely new project will be created.

Here is an example of how you would export a project and then re-import it to update the settings:

ncover project-export --file="C:\MyPath\return-of-the-override" --project="Return Of The Override"

Modify the exported JSON file to change the project settings

ncover project-import --file="C:\MyPath\return-of-the-override.json" --project="Return Of The Override" --overwrite

Please reference Import Project Settings in the NCover Documentation for additional details.

Create A New NCover Project From the Command Line

Finally, the Import Project command can also be used to create a new project from a settings file.  The steps for creating a new project are the same as for importing a project EXCEPT THAT YOU DO NOT USE the overwrite command when using the Project Import command.

Please reference Create A Project in the NCover Documentation for additional details.