NCoverExplorer.MSBuildTasks Logging levels to use within NCover task. No logging. Writes standard log output (Default). Writes verbose log output. New element option introduced in NCover 1.5.7 for use with //x2 argument. Legacy xml format that is the default. New xml format introduced in NCover 1.5.7 that nests method nodes with class nodes. Sort order for displaying the coverage results in the tree. Sort by name (default). (0) Sort by name( down to class level) then by line within the class. (1) Sort by coverage percentage ascending. (2) Sort by coverage percentage descending. (3) Sort by unvisited lines ascending. (4) Sort by unvisited lines descending. (5) Sort by visit count ascending. (6) Sort by visit count descending. (7) Sort by function coverage ascending. (8) Sort by function coverage descending. (9) Filter styles that can be applied to the results. Filtered nodes are not excluded from the coverage statistics. No filter applied. (0) Hide unvisited nodes. (1) Hide 100% fully covered nodes. (2) Hide nodes exceeding coverage threshold. (3) Potential report types. None. (0) Modules summary only. (1) Modules summary followed with a namespaces by module summary. (3) Modules summary followed with a classes by namespace summary. (4) Modules summary followed with a classes by namespace summary showing function coverage. (5) Common utility functions for working with NCover. Registry key for registering NCover manually - this will all become unnecessary in future versions of NCover (post 1.5.5) hopefully. Builds the temp settings XML file for NCover. The version. The ncover path. The settings file. The command line exe. The command line args. The working directory. The assembly list. The assembly files. The coverage file. The log level. The log file. The exclude attributes. If set to true profile IIS. The profile service. The XML format to write out (new feature in 1.5.7). Name of the profiled process. Command line switch necessary for passing as an argument. Creates the command line arguments. The version. The ncover path. The command line exe. The command line args. The working directory. The assembly list. The coverage file. The log level. The log file. The exclude attributes. if set to true [profile IIS]. The profile service. if set to true include formatting. Whether to register CoverLib.dll. The command line format token. Registers the NCover coverlib.dll by writing directly into the registry under HKCU. Keeps a reference count so only register if only NCover task currently running. Unregisters the NCover coverlib.dll Keeps a reference count so only unregister if last NCover task currently running. Find path to NCover console and retrieve the version info. Reads the file contents and returns as a string. Build the Xml .ncoversettings file to pass to the NCover.Console executable using NCover 1.3.3 syntax. Write assembly names as a semi-colon delimited unique assembly name list. Assembly names do not have extensions (how NCover requires them) to match how the CLR identifies them when being profiled. Build the Xml .ncoversettings file to pass to the NCover.Console executable using NCover 1.5 syntax. Writes assembly names as separate Assembly nodes in the settings file. Seems to be a difference in how NCover 1.5.4 onwards handles from previous versions in the xml. Build a command line using NCover 1.3.3 syntax. Build a command line using NCover 1.5.x syntax. Creates the necessary HKCU entries for the NCover coverlib.dll. The ncover path. Handles a control-C style event so we can cleanup our refcount. Type of control exit. Whether to cancel the event. Utility class to scan for an executable in all available paths. Based on CodeProject article at: http://www.codeproject.com/csharp/winwhich.asp Initializes a new instance of the class. Return the version information for the executable located at this path. If executable not found at this location (e.g. not a fully qualified path) does a path search to see if it can be found anywhere else. Path to executable to find. Whether to throw exception if not found. Version number in format Major.Minor.Build Searches for the specified executable name in all available paths. Name of the executable. Form the regular expression string for the matching file. The name of the executable string that is the regex pattern. MSBuild task for automating NCoverExplorer.Console. Using this task you can merge coverage files from NCover, produce xml coverage reports for use with CruiseControl.Net, produce html report files directly, fail automated builds if coverage thresholds are not met and apply a range of detail to the reports produced such as sorting, filtering and coverage exclusions. This example shows producing an xml coverage report at Module/Namespace/Class detail level for inclusion on a CC.Net build server. You would add a merge file task in the publishers section of your CC.Net project file to merge in this "CoverageSummary.xml" file so that it can be transformed by the NCoverExplorer xsl stylesheets you have copied into the CC.Net folder. Here we have set a satisfactory coverage threshold at 80%. ]]> This example shows producing an html function coverage report, excluding the test assemblies. The assemblies excluded are being displayed at the bottom of the report. Note also that this time the ReportType is specified by its enum name rather than numeric value - they are interchangable. We have also "inlined" the "CoverageFiles" from the ItemGroup above to show this can be done. Assembly *.Tests ]]> This example shows producing an html module class summary coverage report with exclusions as above. This time we have added applying specific sorting and filtering criteria. This report will show all classes that do not have 100% coverage, sorted within their namespaces by descending coverage %. We have also "inlined" the exclusions ]]> This example shows the merging capability to produce a consolidated merge file from multiple coverage test runs. The results are being stored in a single "MyApp.CoverageMerged.xml" file. Note that you could additionally apply coverage exclusions at this point. Merging files can be useful if your testing process requires multiple coverage runs and you want a single archive which consolidates the results. ]]> This example shows failing a build if the overall coverage % does not meet our threshold, without producing a coverage report. ]]> This example shows failing a build if either the overall coverage % does not meet our threshold, or if one of the individual module thresholds is not met. Note that the ModuleThresholds could have been "inlined" (just showing the MSBuild flexibility to place in a separate group). ]]> This example shows using virtually the whole range of attributes. Shown below is failing a build if not reaching the overall or module level coverage thresholds. The results of merging multiple NCover files together are stored as a separate file. We are producing xml and html Namespace per module summary reports (with the exclusions show in the footer). Note that the module thresholds will also be used in the reports. The reports are sorted by name with no filter applied. We are excluding test assemblies and anything in a presentation layer namespace. Class MyApp.SomeNamespace.SomeClass Namespace MyApp\.(\w*\.)? true ]]> Initializes a new instance of the class. Validate the parameters supplied to this task. true if parameters are valid, false otherwise. Executes the task. if the task ran successfully; otherwise . Returns a string value containing the command line arguments to pass directly to the executable file. A string value containing the command line arguments to pass directly to the executable file. Logs the starting point of the run to all registered loggers. A descriptive message to provide loggers, usually the command line and switches. Returns the fully qualified path to the executable file. The fully qualified path to the executable file. Determine the path to NCoverExplorer. Either the user can specify it in the arguments to the task, or we look in the registry, program files and finally just assume it is in the path. Return a temporary filename for the config file for executing NCoverExplorer.Console. Configuration filename. Legacy NCoverExplorer.Console is considered prior to 1.4.0 (as 1.4.0 was when the settings file format was changed). NCoverExplorer.Console.exe path. true if version is prior to 1.4.0 Builds a temporary NCoverExplorer configuration file which we can pass in the command line. We require this as the command line itself does not directly support all the argument combinations. Name of the settings file. Builds a temporary NCoverExplorer configuration file which we can pass in the command line. We require this as the command line itself does not directly support all the argument combinations. Name of the settings file. The coverage exclusions have been inlined as type=pattern semi-colon delimited pairs. Break apart and write to the temp config file. Current xml output stream. The coverage exclusions have been inlined as type=pattern semi-colon delimited pairs. Break apart and write to the temp config file. Current xml output stream. Iterate through the module thresholds and write their values into the configuration file. Current xml output stream. Build command line for passing to legacy NCoverExplorer.Console versions. Removes generated settings file after process has run. Gets or sets the output directory for the reports. The output dir. Whether to fail the task if the minimumCoverage threshold is not reached on any module. NCoverExplorer console application will return exit code 3. Whether to fail the task if the minimumCoverage threshold is not reached on total coverage. NCoverExplorer console application will return exit code 3. The minimum coverage percentage to be used with the FailMinimum and FailCombinedMinimum options. Gets or sets the name of the temporary XML config file being generated for coverage. The name of the XML config. The satisfactory coverage percentage for display in the reports. The .config filename for containing any custom exclusions and parameters. The type of report to produce (use numeric value or string name). 0 / None, 1 / ModuleSummary, 3 / ModuleNamespaceSummary, 4 / ModuleClassSummary, 5 / ModuleClassFunctionSummary The sorting if any to apply (use numeric value or string name). 0 / Name, 1 / ClassLine, 2 / CoveragePercentageAscending, 3 / CoveragePercentageDescending, 4 / UnvisitedSequencePointsAscending, 5 / UnvisitedSequencePointsDescending, 6 / VisitCountAscending, 7 / VisitCountDescending, 8 / FunctionCoverageAscending, 9 / FunctionCoverageDescending The filtering if any to apply (use numeric value or string name). 0 / None, 1 / HideUnvisited, 2 / HideFullyCovered, 3 / HideThresholdCovered The string or textual enum value. The filename for generating an xml report. The filename for generating an html report. The filename for the merge of the coverage xml files. Determines whether to include the coverage exclusions in the report. The default is . Used to select the coverage xml files to merge into the report. Coverage exclusions to apply, in one of two formats: They can be semi-colon delimited "Type=Pattern" pairs, e.g. "Assembly=*.Tests;Class=My.*". Alternatively they can be defined in a property group as a <CoverageExclusions> section. See the examples for both formats. If you want to use regular expressions then you must use the <PropertyGroup> approach. This example shows a range of coverage exclusions using the <PropertyGroup> approach. Note the optional use of wildcard characters in the pattern. You could set the exclusions up within the gui and then paste the xml directly from the NCoverExplorer.config file located in C:\Documents and Settings\user\Application Data\Gnoso\NCoverExplorer\ Assembly *.Tests Namespace MyNamespace.* Class MyNamespace.MyClass Method MyNamespace.MyClass.MyMethod Namespace MyApp\.(\w*\.)? true ]]> This example shows inlining of three of the same exclusions above. Note with this approach it is not possible to use regular expressions. ]]> Module thresholds to apply, in format "AssemblyName=Percentage", e.g. "MyApp.Core=75" Gets the name of the executable file to run. The name of the executable file to run. Gets the with which to log errors. The with which to log errors. MSBuild task for automating NCover.Console.exe, with NCover 1.5.x support. Note that this task will self register CoverLib.dll by default using the registry (does not require local admin). This example shows the standard profiling using NCover for standard nunit tests with minimal arguments. Defaults are with logging to coverage.log, profiling all assemblies, output filename of coverage.xml and this example specifies a path to where to find ncover.console.exe. ]]> If you are using TypeMock, you may experience issues with the registration of coverlib.dll conflicting due to overwriting the registered profiler. You should add the "registerProfiler" attribute below and set it to false. ]]> This example for NCover 1.5.8 shows profiling a process which is launched by another process. ]]> This example shows using an assembly list as ; delimited names rather than using the ability of the NCover task to dynamically build from a list of files (shown in following example). ]]> This example shows the standard profiling using NCover 1.5.x for a Windows application, specifying a coverage exclusion, verbose logging to a named file, specifically named log and output xml files. It also shows coverage exclusion attributes, overriding the NCover location to run from and a way of listing assemblies to be included in the profiled NCover results. ]]> Initializes a new instance of the class. Executes the task. if the task ran successfully; otherwise . Returns a string value containing the command line arguments to pass directly to the executable file. A string value containing the command line arguments to pass directly to the executable file. Returns the fully qualified path to the executable file. The fully qualified path to the executable file. Logs the starting point of the run to all registered loggers. A descriptive message to provide loggers, usually the command line and switches. Check that we have a valid path to NCover. Removes generated settings file after process has run. Convert the MSBuild specific ITaskItem[] to a string array for use by NCoverUtilities. The command line executable to be launched by NCover (such as nunit-console.exe). The arguments to pass to the command line executable to be launched by NCover (such as nunit-console.exe). The filename for the output coverage.xml file (default). What level of NCover logging to provide. Values are "Normal" (default) and "Verbose". Due to a bug in NCover 1.5.4 "Quiet" will result in NCover stopping abnormally - hence has been defaulted to be "Normal" until the bug is fixed. Gets or sets the logfile name to write to if logLevel is set to anything other than "Quiet". The default is "coverage.log". Gets or sets the working directory for the command line executable. If coverage exclusion attributes have been applied (NCover 1.5.4 onwards) specify the full namespace to the attribute including the "Attribute" suffix - e.g. "CoverageExcludeAttribute" if defined in no namespace. Separate multiple attributes with semi-colons. Determines whether to profile under IIS. Default value is . The service name if profiling a windows service. Alternative to specifying assembly names - you can instead list them as you would on the command line as a semi-colon delimited list without any suffixes or paths. Used to specify the assemblies to be profiled. Alternative to the AssemblyList property, where instead you wat the list to be dynamically built using an itemgroup, for instance to match all assemblies against a wildcard. The NCover task will take care of stripping off the suffixes etc. Determines whether to register NCover CoverLib.dll on each run. The default is true. You would set this to false if using TypeMock due to a conflict in registered profilers. If set to true, the NCover task uses a reference counting approach to minimise the chance of issues when simultaneous builds. Gets or sets a value indicating the xml output format to write (new in NCover 1.5.7). Default value is "Xml1", alternat option is "Xml2" which nests method nodes within class nodes. Note however that "Xml2" is for future use and is not yet supported by NCoverExplorer as of version 1.3.6. Gets or sets the profiled process module name. Use this argument when the executable being launched is not the actual process you want to profile coverage for. Gets the name of the executable file to run. The name of the executable file to run. Gets the with which to log errors. The with which to log errors. Create a .nunit project file for all the test assemblies matching the specified pattern. This should be created in the bin folder where your test assemblies are located so that the assemblies are within the AppDomain path. The .nunit file can then be used by NUnit or NCover based tasks. Create a .nunit project file in output bin folder for a specified test assembly. $(MSBuildProjectDirectory)\Build ]]> Create a .nunit project file in output bin folder with an associated App.Config file for all test assemblies matching a pattern. ]]> Default constructor. Build the contents of the .nunit file using the test assemblies matching this pattern. Create a .nunit project file listing the test assemblies. Full filename of the .nunit file. Fileset containing the test assemblies. Optional path to App.Config file to include in project. Optional path to the nunit app base, when included full paths to each assembly (relative to the appbase) are included The nunit project file to create. Optional path to an App.Config file to be specified in the .nunit project file. Optional path to the nunit app base, when included full paths to each assembly (relative to the appbase) are included. Used to select the test assemblies to be included in the .nunit project. A strongly-typed resource class, for looking up localized strings, etc. Returns the cached ResourceManager instance used by this class. Overrides the current thread's CurrentUICulture property for all resource lookups using this strongly typed resource class. Looks up a localized string similar to Contents of config file:\r\n{0}. Looks up a localized string similar to Contents of config file:\r\n{0}. Looks up a localized string similar to Deleting config file: {0}. Looks up a localized string similar to This line cannot be parsed: '{0}'. Coverage exclusions should be in format: Type=Pattern (e.g. 'Assembly=*.Tests'). Looks up a localized string similar to Could not find the registry key for NCoverExplorer indicating the program location (set by installing with TestDriven.Net). Please specify the full path to NCoverExplorer.Console.exe using the ToolPath attribute.. Looks up a localized string similar to Could not find NCover.Console.exe in C:\Program Files\NCover\. Specify an alternate path using the ToolPath attribute on your NCover target.. Looks up a localized string similar to Detected NCover.Console v{0} in {1}.