Description: Print environment changes needed for coverage collection to be assigned exclusively to one project and optionally register COM dlls for profiling, start/stop NCover service, etc.
The Use command prints out the SET statements that you need to incorporate into your build process. It requires you to manually set those environment values in your build scripting.
Currently, we can't add environment variables to a parent process (i.e. the build environment) after the build has started, so the USE command generates a project ID that's added to the build using the SET parameters.
Note: The Use command is also available as a parameter in the NCover Run command.
NCover Use --project="Sample WPF App" --script=msbuild --buildId="123456" --reg-dlls
--project NCover project name.
--script Specify the environment scripting to use:'batch', 'msbuild'
--buildId Specify the build Id for this execution.
--reg-dlls Register the coverage launcher and profiler with Windows.
--unreg-dlls Unregister the coverage launcher and profiler with Windows.
--start-svc Start the NCover Windows service.
--stop-svc Stop the NCover Windows service.
--clear Clear the exclusive project settings.
--silent Don't print messages.
The primary purpose of USE is project isolation. The following is a sample command which prints environment settings for you to use within your environment. These are DOS 'SET' commands and there is nothing special here, except the names of our variables and the values specific to your project.
Type the following from the command prompt:
ncover use --project="MyProject" --buildId="1234567.8"
This will print out the following SET commands for use in your build environment:
If you specify "ncover use --clear" you will get the following environment commands: SET NCOVER_USING_PROJECT= SET NCOVER_BUILD_ID=
Using the first SET commands, alternately with SET clear commands, you can isolate coverage to a specific process within your build.
The USE command is provided to give you easy access to the project keys stored in the NCover database. The NCOVER_USING_PROJECT must be an ID, not a project name. This ID is the same on Code Central and on the local machines which receive the CC projects so the same SETs work to identify a specific project globally. This is designed so project names can be changed, but project use commands don't have to change.
Additionally, you can set the NCOVER_BUILD_ID variable within your build environment. This will label all executions collected with the same BUILD_ID while the variable is defined in the execution environment.
These commands are not as transparent, since they must work across the server and the profiler. The profiler is not a .NET app so environment vars are the best way to provide information to the profiler for control purposes.
NAnt and MSBuild have varying features and extensions that can manipulate the process environment. You can choose to set these environment variables in any way that works best for you. The key is that these vars get set for the process that will execute your coverage run. Typically child processes inherit the parent process environment, but if that is not the case in your scenario, you will want to be careful to propagate the environment as needed.