TeamCity failing to generate DotCover reports from custom build script

2.9k views Asked by At

What do I need to do to get TeamCity to properly generate coverage reports against my project?

I've got a custom powershell build script running DotCover against my code. The build script has a coverage method like so

Function Invoke-NUnitWithCoverage ( [string] $targetAssembly, [string] $outputDir, [string] $runCommand){
    $fileName = Get-TestFileName $outputDir $runCommand

    $xmlFile = "$fileName-TestResults.xml"
    $txtFile = "$fileName-TestResults.txt"
    $coverageFile = "$fileName-CoverageResults.xml"

    exec{ dotcover.exe analyse /TargetExecutable=$nunitRunnerDir\nunit-console.exe /TargetArguments="$targetAssembly /fixture:$runCommand /xml=$xmlFile /out=$txtFile /nologo /framework=4.0" /Output=$coverageFile /ReportType=xml  } "Running code coverage '$runCommand' failed."
    Write-Host "##teamcity[importData type='dotNetCoverage' tool='dotcover' path='$coverageFile']"
}

The output appears correct on TeamCity, however it's not generating the report. Here's the TeamCity Log. As you can see, there are generation failures.

TL;DR;
If you don't want to read the entire log, here are the key lines.

[JetBrains dotCover] Failed to merge snapshots. Unknown storage type. Unknown storage type
...
[JetBrains dotCover] Unhandled exception: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
...
[JetBrains dotCover] Report generation failed. Too short file
...
[JetBrains dotCover] Failed to create zipped snapshot. Too short file
...
[JetBrains dotCover] 'E:\BuildAgent\temp\buildTmp\dotCover5237101456909205485Merge' is not a coverage snapshot. 
##teamcity[importData type='dotNetCoverage' tool='dotcover' path='E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-App-Tests-CoverageResults.xml']
....
....
Waiting for 16 service processes to complete
[10:32:34]Processing 1 coverage report(s)
[10:32:34]Generating coverage report by dotcover for files: [E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-App-Tests-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-Framework-Test-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-CommonDataService-Tests-Unit-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-Contracts-Tests-Unit-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-Invoicing-Tests-Unit-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-FlowingGasService-Tests-Unit-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-JobSchedulingService-Tests-Unit-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-CommonDataService-Tests-Integration-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-Contracts-Tests-Integration-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-Invoicing-Tests-Integration-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-FlowingGasService-Tests-Integration-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-JobSchedulingService-Tests-Integration-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-CommonDataService-Tests-Acceptance-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-Contracts-Tests-Acceptance-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-FlowingGasService-Tests-Acceptance-CoverageResults.xml, E:\BuildAgent\work\81eb7c2fdfcfc0af\build-artifacts\results\TransCanada-GCTS-Invoicing-Tests-Acceptance-CoverageResults.xml]
[10:32:34]Get dotCover version (1s)
[10:32:35]Started dotCover: E:\BuildAgent\tools\dotCover\dotCover.exe version E:\BuildAgent\temp\buildTmp\dotCover2609519531914093171Version
[10:32:35]
Output: JetBrains dotCover Console Runner v2.7.2.84. Copyright (c) 2009-2014 JetBrains s.r.o. All rights reserved.
[10:32:35]dotCover exited with code: 0
[10:32:35]Use DotCover 2.7.x commands set
[10:32:35]Merge dotCover reports (10s)
[10:32:45]Started dotCover: E:\BuildAgent\tools\dotCover\dotCover.exe merge E:\BuildAgent\temp\buildTmp\dotcover6392358845042650216.xml
[10:32:45]
Output: JetBrains dotCover Console Runner v2.7.2.84. Copyright (c) 2009-2014 JetBrains s.r.o. All rights reserved.
[JetBrains dotCover] Snapshot merging started [12/3/2014 10:32:44 AM]
[JetBrains dotCover] Source snapshots number: 16
Merging snapshots 1-5
[JetBrains dotCover] Failed to merge snapshots. Unknown storage type. Unknown storage type
[10:32:45]dotCover exited with code: -2
[10:32:45]dotCover returned non-zero exit code.
[10:32:45]Remove dotCover snapshot files
[10:32:45]Started dotCover: E:\BuildAgent\tools\dotCover\dotCover.exe delete E:\BuildAgent\temp\buildTmp\dotcover4610370083173723447.xml
[10:32:45]
Output: JetBrains dotCover Console Runner v2.7.2.84. Copyright (c) 2009-2014 JetBrains s.r.o. All rights reserved.
[JetBrains dotCover] Unhandled exception: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
[10:32:45]dotCover exited with code: -10
[10:32:45]dotCover returned non-zero exit code.
[10:32:45]Generate dotCover report (7s)
[10:32:52]Started dotCover: E:\BuildAgent\tools\dotCover\dotCover.exe report E:\BuildAgent\temp\buildTmp\dotcover8678535704262330052.xml
[10:32:52]
Output: JetBrains dotCover Console Runner v2.7.2.84. Copyright (c) 2009-2014 JetBrains s.r.o. All rights reserved.
[JetBrains dotCover] Report generation started [12/3/2014 10:32:45 AM]
[JetBrains dotCover] Report generation failed. Too short file
[10:32:52]dotCover exited with code: -2
[10:32:52]dotCover returned non-zero exit code.
[10:32:52]Generate dotCover HTML report
[10:32:52]Packing snapshot files (6s)
[10:32:59]Started dotCover: E:\BuildAgent\tools\dotCover\dotCover.exe zip E:\BuildAgent\temp\buildTmp\dotcover1602620273009840026.xml
[10:32:59]
Output: JetBrains dotCover Console Runner v2.7.2.84. Copyright (c) 2009-2014 JetBrains s.r.o. All rights reserved.
[JetBrains dotCover] Failed to create zipped snapshot. Too short file
[10:32:59]dotCover exited with code: -2
[10:32:59]dotCover returned non-zero exit code.
[10:32:59]Remove dotCover snapshot files (6s)
[10:33:06]No statistics values are provided by dotCover report generator (recommended)
1

There are 1 answers

3
Alina Mishina On BEST ANSWER

For dotCover you should send paths to the snapshot (dotCover.snapshot) file that is generated by the dotCover.exe cover command, not .xml file.