Trouble using ncoverexplorer with msbuild

Trouble using ncoverexplorer with msbuild

Hi Im trying to do something that looks fairly simple but the msbuild task for ncoverexplorer seems to be faulty.

I have the following three tasks as a part of a target NUnitProject Project="$(SolutionPath)\Build\MyApp.nunit" Assemblies="@(TestAssembly)" /> <!--NCover Assemblies="$(AssemblyPath)\*.dll" CoverageFile="$(ArtifactsPath)\Coverage.xml" CoverageHtmlDirectory="$(ArtifactsPath)\Coverage" ProjectName="My Project" CommandLineExe="$(SolutionPath)\ExternalAssemblies\NUnit\nunit-console.exe" CommandLineArgs="$(SolutionPath)\Build\MyApp.nunit /xml="$(ArtifactsPath)\TestResult.xml"" ContinueOnError="true" FileExclusionPatterns="$(CoverageExclusions)" /> <Message Text="Blah"/-->

<NCoverExplorer ProjectName="My Project"
                OutputDir="$(ArtifactsPath)\Coverage1"
                CoverageFiles="$(ArtifactsPath)\Coverage.xml"
                SatisfactoryCoverage="80"
                ReportType="ModuleClassFunctionSummary"
                HtmlReportName="CoverageSummary.html"
                Exclusions="$(CoverageExclusions)"
                ShowExcluded="True"/>

The purpose of this is to run all the tests and generate a html report with the expected exclusions. Now when I run this from the command line the error I see is

"Build.proj" (NunitCoverage target) (1) -> (NunitCoverage target) -> Build.proj(139,5): error MSB6001: Invalid command line switch for "NCoverExplorer.Conso le.exe". Value cannot be null.\r Build.proj(139,5): error MSB6001: Parameter name: path1

Any help would be appreciated. Id also like to know how I can fail the build when tests fail AND still get a coverage report? This method requires me to continueonerror because I need ncoverexplorer to run.

thanks


RE: Trouble using ncoverexplorer with msbuild

What version of NCover are you using?

Thanks,

Joe Feser


RE: Trouble using ncoverexplorer with msbuild

the tag looks like it's malformed. what does it end w/ "/>"?


RE: Trouble using ncoverexplorer with msbuild

Hi. Regarding the malformed nature, thats just a typo while pasting it to the web I think. I was struggling with this for quite a while commenting and uncommenting stuff.

The version of ncover is 2.1.2.3433. The ncoverexplorer gui itself works fine. Its just the msbuild task.

whoops correction. I had said 3.0.11.4379 but that was wrong. The version is 2.1.2.3433


RE: Trouble using ncoverexplorer with msbuild

shouldn't the "Exclusions="$(CoverageExclusions)"" line have the '$' changed to a '@'


RE: Trouble using ncoverexplorer with msbuild

Hi,

this is a MSBuild problem, not one of NCover.

I can say that because I am experiencing exactly the same error at the moment with MSBuild, but using a different task.

You can assert that by executing the command line that MSBuild reports in its log directly.

As soon as I found out, what the problem is, I'll post the solution (or workaround) here.

Regards Thomas


RE: Trouble using ncoverexplorer with msbuild

It seems that there can be an issue in MSBuild when these circumstances apply: - The task in question derives from ToolTask (what ncoverexplorer does) - There must be a quoted path somewhere (usually because it has one ore more blanks in it as e.g. in 'C:\Program Files') - MSBuilds console logger or/and file logger is/are involved.

After I've made a lot of trials I guess that the MSBuild error happens when an underlying command line tool tries to report back such a path to MSBuild and MSBuild wants to log this message.

So indeed your problem can possibly be solved by fixing the ncoverexplorer task...

As for now, I can think of two possible workarounds: - Disable MSBuilds console logging (using '/noconsolelogger') - Use MSBuilds 'Exec' task instead.

The first 'solution' may not be appropriate if you are using this on CC.Net. I haven't checked it, but it seems to me that CC.Net uses the MSBuild filelogger internally. So problems may re-enter the stage on an automation server.

Note that the NCover GUI program can automatically produce an Exec task with the appropriate settings for you, so 'solution' #2 seems to be, though not really elegant, at least quite handy.

Regards Thomas