CodeCoverage not found when installed by Visual Studio Test Platform Installer

I’m using the “Visual Studio Test Platform Installer” in Azure DevOps, which installs the Microsoft.TestPlatform nuget package. This tool provides CodeCoverage.exe. However SonarQube doesn’t discover this tool:

2019-02-18T14:09:21.1495521Z 15:09:21.149  Attempting to locate the CodeCoverage.exe tool...
2019-02-18T14:09:21.1535493Z 15:09:21.153  Attempting to locate the CodeCoverage.exe tool using setup configuration...
2019-02-18T14:09:21.1655459Z 15:09:21.165  Attempting to locate the CodeCoverage.exe tool using registry...
2019-02-18T14:09:21.1695696Z 15:09:21.168  15:09:21.168  WARNING: Failed to find the code coverage command line tool. Possible cause: Visual Studio is not installed, or the installed version does not support code coverage.

As a workaround, I now generate the coverage XML manually, adapted from a workaround posted to the mailing list.

variables:
  testPlatformVersion: 15.9.0
steps:
- task: VisualStudioTestPlatformInstaller@1
  displayName: 'Visual Studio Test Platform Installer'
  inputs:
    versionSelector: specificVersion
    testPlatformVersion: '$(testPlatformVersion)'
# steps to prepare, build, test, analyze etc
- powershell: |
   $cc = "$(Agent.ToolsDirectory)\VsTest\$(testPlatformVersion)\x64\tools\net451\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe"
   $root = '$(Build.SourcesDirectory)\TestResults'
   $trxFile = (Get-ChildItem -Path $root -Filter *.coverage -Recurse | Select-Object -First 1).fullname
   $guid = New-Guid
   $out = "$root\$guid.coveragexml"
   &$cc analyze /output:$out $trxFile
   exit 0
  displayName: 'Convert coverage report to xml'

Hello?

I have the same problem. Any solution?

Hi,

Currently we only look for Visual Studio Enterprise installation to get the path to the coverage tool.

I opened a ticket, let’s see what we can do on that : https://github.com/SonarSource/sonar-scanner-msbuild/issues/798

Thanks.

Mickaël

That’s a great start I think. In this particular case I’m using VisualStudioTestPlatformInstaller, which installs the latest test platform, it would be great if Sonar could also automatically detect that installation. Then I wouldn’t need to do such configuration, similar to how the VsTest task uses that installation.

Hello Bouke,
I am trying to use the above script, where i installed the codecoverage.exe through the visual test installer task. But then , the script errors with codecoverage.exe not a valid cmdlet. Can you plz let me know what wrong i am doing?

$tool= Get-ChildItem -Path '$(Agent.ToolsDirectory)\F:\vsts-agent-win-x64-2.149.2_work_tool\VsTest\16.5.0\x64\tools\net451\Team Tools\Dynamic Code Coverage Tools' -Filter CodeCoverage.exe -Recurse -ErrorAction SilentlyContinue -Force

$parameter1 = ‘analyze’
$parameter2 = ‘/output: $(Agent.BuildDirectory)\TestResults\TestCoverage.coveragexml’
$parameter3 = ‘$(Agent.BuildDirectory)\TestResults\TestCoverage.coverage’
$parameters= “$parameter1 $parameter2 $parameter3”

Write-Host “Executing $tool $parameters”
$parms = $parameters.Split(" ")
& $tool $parms

i also tried the above using commandline as outlined here.

“$(Agent.ToolsDirectory)\F:\vsts-agent-win-x64-2.149.2_work_tool\VsTest\16.5.0\x64\tools\net451\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe” analyze /output: “$(Agent.BuildDirectory)\TestResults\TestCoverage.coveragexml” “$(Agent.BuildDirectory)\TestResults\TestCoverage.coverage” /verbose

=============================================================================
when run thro command line: it gives me a different error, demanding a usage:
2020-03-04T17:48:48.3038110Z ========================== Starting Command Output ===========================
2020-03-04T17:48:48.3134276Z ##[debug]Entering Invoke-VstsTool.
2020-03-04T17:48:48.3232964Z ##[debug] Arguments: ‘/D /E:ON /V:OFF /S /C “CALL “F:\vsts-agent-win-x64-2.149.2_work_temp\b4a26cc7-572f-4977-9f2c-8e999fba30ce.cmd””’
2020-03-04T17:48:48.3250081Z ##[debug] FileName: ‘C:\Windows\system32\cmd.exe’
2020-03-04T17:48:48.3267810Z ##[debug] WorkingDirectory: ‘F:\vsts-agent-win-x64-2.149.2_work\1\s\WrittenNotificationServices\src’
2020-03-04T17:48:48.3315354Z ##[command]“C:\Windows\system32\cmd.exe” /D /E:ON /V:OFF /S /C “CALL “F:\vsts-agent-win-x64-2.149.2_work_temp\b4a26cc7-572f-4977-9f2c-8e999fba30ce.cmd””
2020-03-04T17:48:48.3408923Z “what is CD…” F:\vsts-agent-win-x64-2.149.2_work\1\s\WrittenNotificationServices\src
2020-03-04T17:48:48.3504864Z M i c r o s o f t ( R ) C o v e r a g e C o l l e c t i o n T o o l V e r s i o n 1 6 . 0 . 3 0 3 1 9 . 0
2020-03-04T17:48:48.3505933Z
2020-03-04T17:48:48.3505998Z
2020-03-04T17:48:48.3506120Z C o p y r i g h t ( c ) M i c r o s o f t C o r p o r a t i o n . A l l r i g h t s r e s e r v e d .
2020-03-04T17:48:48.3506209Z
2020-03-04T17:48:48.3506266Z
2020-03-04T17:48:48.3506337Z
2020-03-04T17:48:48.3506410Z
2020-03-04T17:48:48.3506506Z
2020-03-04T17:48:48.3506562Z
2020-03-04T17:48:48.3506650Z U s a g e : C o d e C o v e r a g e < c o m m a n d >
2020-03-04T17:48:48.3506731Z
2020-03-04T17:48:48.3506786Z
2020-03-04T17:48:48.3506856Z
2020-03-04T17:48:48.3506910Z
2020-03-04T17:48:48.3506965Z
2020-03-04T17:48:48.3507035Z
2020-03-04T17:48:48.3507151Z C o l l e c t c o v e r a g e d a t a t o t h e g i v e n c o v e r a g e f i l e .
2020-03-04T17:48:48.3507227Z
2020-03-04T17:48:48.3507282Z
2020-03-04T17:48:48.3507386Z U s a g e : c o l l e c t [ o p t i o n s ] [ c o m m a n d l i n e ]
2020-03-04T17:48:48.3507463Z
2020-03-04T17:48:48.3507526Z
2020-03-04T17:48:48.3507603Z O p t i o n s :
2020-03-04T17:48:48.3507664Z
2020-03-04T17:48:48.3507718Z
2020-03-04T17:48:48.3507808Z / c o n f i g : < p a t h >
2020-03-04T17:48:48.3507870Z
2020-03-04T17:48:48.3507936Z
2020-03-04T17:48:48.3508079Z [ o p t i o n a l ] O v e r r i d e d e f a u l t c o n f i g u r a t i o n w i t h c o n f i g u r a t i o n f i l e
2020-03-04T17:48:48.3508159Z
2020-03-04T17:48:48.3508215Z
2020-03-04T17:48:48.3508289Z s p e c i f i e d .
2020-03-04T17:48:48.3508363Z
2020-03-04T17:48:48.3508418Z
2020-03-04T17:48:48.3508472Z
2020-03-04T17:48:48.3508538Z
2020-03-04T17:48:48.3508591Z
2020-03-04T17:48:48.3508669Z / I I S
2020-03-04T17:48:48.3508730Z
2020-03-04T17:48:48.3508784Z
2020-03-04T17:48:48.3508926Z [ o p t i o n a l ] C o l l e c t c o d e c o v e r a g e f o r w e b a p p l i c a t i o n s r u n n i n g
2020-03-04T17:48:48.3509000Z
2020-03-04T17:48:48.3509064Z
2020-03-04T17:48:48.3509196Z u n d e r I n t e r n e t I n f o r m a t i o n S e r v i c e ( I I S ) . I I S W o r k e r p r o c e s s
2020-03-04T17:48:48.3509272Z
2020-03-04T17:48:48.3509335Z
2020-03-04T17:48:48.3509477Z ( w 3 w p . e x e ) w i l l b e r e g i s t e r e d f o r c o l l e c t i o n a n d a l l t h e a p p l i c a t i o n
2020-03-04T17:48:48.3509557Z
2020-03-04T17:48:48.3509612Z
2020-03-04T17:48:48.3509714Z p o o l s w i l l b e r e s t a r t e d .
2020-03-04T17:48:48.3509778Z
2020-03-04T17:48:48.3509833Z
2020-03-04T17:48:48.3509897Z
2020-03-04T17:48:48.3510013Z
2020-03-04T17:48:48.3510124Z
2020-03-04T17:48:48.3510206Z / o u t p u t : < p a t h >
2020-03-04T17:48:48.3510268Z
2020-03-04T17:48:48.3510339Z
2020-03-04T17:48:48.3510520Z [ r e q u i r e d ] T h e f i l e t o o u t p u t c o v e r a g e d a t a t o .
2020-03-04T17:48:48.3510598Z
2020-03-04T17:48:48.3510653Z
2020-03-04T17:48:48.3510716Z
2020-03-04T17:48:48.3510770Z
2020-03-04T17:48:48.3510836Z
2020-03-04T17:48:48.3510917Z / s e s s i o n : < n a m e >
2020-03-04T17:48:48.3511123Z
2020-03-04T17:48:48.3511196Z
2020-03-04T17:48:48.3511331Z [ o p t i o n a l ] T h e n a m e f o r t h e s e s s i o n . I f a s e s s i o n n a m e i s n o t
2020-03-04T17:48:48.3511488Z
2020-03-04T17:48:48.3511561Z
2020-03-04T17:48:48.3511677Z p r o v i d e d , a u n i q u e s e s s i o n n a m e w i l l b e u s e d
2020-03-04T17:48:48.3511759Z
2020-03-04T17:48:48.3511814Z
2020-03-04T17:48:48.3511883Z
2020-03-04T17:48:48.3511937Z
2020-03-04T17:48:48.3511990Z
2020-03-04T17:48:48.3512075Z / v e r b o s e
2020-03-04T17:48:48.3512134Z
2020-03-04T17:48:48.3512550Z
2020-03-04T17:48:48.3512694Z [ o p t i o n a l ] T u r n o n p r i n t i n g o f d i a g n o s t i c i n f o r m a t i o n d u r i n g r u n t i m e .
2020-03-04T17:48:48.3512775Z
2020-03-04T17:48:48.3512831Z
2020-03-04T17:48:48.3512885Z
2020-03-04T17:48:48.3512956Z
2020-03-04T17:48:48.3513009Z
2020-03-04T17:48:48.3513075Z E x a m p l e :
2020-03-04T17:48:48.3513145Z
2020-03-04T17:48:48.3513199Z
2020-03-04T17:48:48.3513353Z C o d e C o v e r a g e c o l l e c t / I I S / s e s s i o n : W e b S e s s i o n / o u t p u t : M y W e b A p p . c o v e r a g e
2020-03-04T17:48:48.3513422Z
2020-03-04T17:48:48.3513488Z
2020-03-04T17:48:48.3513543Z
2020-03-04T17:48:48.3513653Z S h u t d o w n a l o g g e r w i t h a g i v e n s e s s i o n n a m e .
2020-03-04T17:48:48.3513727Z
2020-03-04T17:48:48.3513782Z
2020-03-04T17:48:48.3513881Z U s a g e : s h u t d o w n [ o p t i o n s ]
2020-03-04T17:48:48.3513951Z
2020-03-04T17:48:48.3514005Z
2020-03-04T17:48:48.3514082Z O p t i o n s :
2020-03-04T17:48:48.3514141Z
2020-03-04T17:48:48.3514204Z
2020-03-04T17:48:48.3514285Z / s e s s i o n : < n a m e >
2020-03-04T17:48:48.3514353Z
2020-03-04T17:48:48.3514417Z
2020-03-04T17:48:48.3514534Z [ r e q u i r e d ] T h e n a m e o f t h e s e s s i o n t o s h u t d o w n
2020-03-04T17:48:48.3514609Z
2020-03-04T17:48:48.3514664Z
2020-03-04T17:48:48.3514718Z
2020-03-04T17:48:48.3514781Z
2020-03-04T17:48:48.3514834Z
2020-03-04T17:48:48.3514912Z E x a m p l e :
2020-03-04T17:48:48.3514970Z
2020-03-04T17:48:48.3515024Z
2020-03-04T17:48:48.3515146Z C o d e C o v e r a g e s h u t d o w n / s e s s i o n : W e b S e s s i o n
2020-03-04T17:48:48.3515210Z
2020-03-04T17:48:48.3515274Z
2020-03-04T17:48:48.3515327Z
2020-03-04T17:48:48.3515461Z A n a l y z e d a t a f r o m o n e o r m o r e c o v e r a g e f i l e s a n d o u t p u t X M L .
2020-03-04T17:48:48.3515538Z
2020-03-04T17:48:48.3515592Z
2020-03-04T17:48:48.3515716Z U s a g e : a n a l y z e [ o p t i o n s ] < f i l e 1 > [ f i l e 2 [ . . . ] ]
2020-03-04T17:48:48.3515788Z
2020-03-04T17:48:48.3515842Z
2020-03-04T17:48:48.3515921Z O p t i o n s :
2020-03-04T17:48:48.3515980Z
2020-03-04T17:48:48.3516045Z
2020-03-04T17:48:48.3516137Z / i n c l u d e _ s k i p p e d _ f u n c t i o n s
2020-03-04T17:48:48.3516200Z
2020-03-04T17:48:48.3516267Z
2020-03-04T17:48:48.3516390Z [ o p t i o n a l ] I n c l u d e s s k i p p e d f u n c t i o n s i n t h e r e s u l t s .
2020-03-04T17:48:48.3516466Z
2020-03-04T17:48:48.3516520Z
2020-03-04T17:48:48.3516585Z
2020-03-04T17:48:48.3516639Z
2020-03-04T17:48:48.3516692Z
2020-03-04T17:48:48.3516801Z / i n c l u d e _ s k i p p e d _ m o d u l e s
2020-03-04T17:48:48.3516865Z
2020-03-04T17:48:48.3516928Z
2020-03-04T17:48:48.3517048Z [ o p t i o n a l ] I n c l u d e s s k i p p e d m o d u l e s i n t h e r e s u l t s
2020-03-04T17:48:48.3517192Z
2020-03-04T17:48:48.3517267Z
2020-03-04T17:48:48.3517321Z
2020-03-04T17:48:48.3517388Z
2020-03-04T17:48:48.3517441Z
2020-03-04T17:48:48.3517522Z / o u t p u t : < p a t h >
2020-03-04T17:48:48.3517593Z
2020-03-04T17:48:48.3517648Z
2020-03-04T17:48:48.3517790Z [ o p t i o n a l ] T h e f i l e t o o u t p u t t h e a n a l y z e d c o v e r a g e d a t a t o
2020-03-04T17:48:48.3517857Z
2020-03-04T17:48:48.3517911Z
2020-03-04T17:48:48.3518025Z T h e d e f a u l t i s t o u s e s t a n d a r d o u t p u t
2020-03-04T17:48:48.3518090Z
2020-03-04T17:48:48.3518155Z
2020-03-04T17:48:48.3518267Z
2020-03-04T17:48:48.3518321Z
2020-03-04T17:48:48.3518390Z
2020-03-04T17:48:48.3518472Z / t e s t : < t e s t i d >
2020-03-04T17:48:48.3518545Z
2020-03-04T17:48:48.3518601Z
2020-03-04T17:48:48.3518731Z [ o p t i o n a l ] T h e t e s t i d e n t i f i e r s t r i n g t o l i m i t t h e c o v e r a g e
2020-03-04T17:48:48.3518821Z
2020-03-04T17:48:48.3518876Z
2020-03-04T17:48:48.3519021Z d a t a t o . T h i s o p t i o n c a n b e s p e c i f i e d m u l t i p l e t i m e s t o m e r g e
2020-03-04T17:48:48.3519088Z
2020-03-04T17:48:48.3519157Z
2020-03-04T17:48:48.3519267Z c o v e r a g e d a t a f o r d i f f e r e n t t e s t s t o g e t h e r
2020-03-04T17:48:48.3519332Z
2020-03-04T17:48:48.3519398Z
2020-03-04T17:48:48.3519451Z
2020-03-04T17:48:48.3519515Z
2020-03-04T17:48:48.3519570Z
2020-03-04T17:48:48.3519636Z E x a m p l e :
2020-03-04T17:48:48.3519711Z
2020-03-04T17:48:48.3519766Z
2020-03-04T17:48:48.3519894Z C o d e C o v e r a g e a n a l y z e / i n c l u d e _ s k i p p e d _ f u n c t i o n s
2020-03-04T17:48:48.3519960Z
2020-03-04T17:48:48.3520014Z
2020-03-04T17:48:48.3520162Z / i n c l u d e _ s k i p p e d _ m o d u l e s / o u t p u t : r e s u l t s . x m l M y W e b A p p . c o v e r a g e
2020-03-04T17:48:48.3520229Z
2020-03-04T17:48:48.3560738Z ##[debug]Exit code: -1
2020-03-04T17:48:48.3595746Z ##[debug]Leaving Invoke-VstsTool.
2020-03-04T17:48:48.3840149Z ##[error]Cmd.exe exited with code ‘-1’.
2020-03-04T17:48:48.3840701Z ##[debug]Processed: ##vso[task.logissue type=error]Cmd.exe exited with code ‘-1’.
2020-03-04T17:48:48.3953612Z ##[debug]Processed: ##vso[task.complete result=Failed]Error detected
2020-03-04T17:48:48.3975409Z ##[debug]Leaving F:\vsts-agent-win-x64-2.149.2_work_tasks\CmdLine_d9bafed4-0b18-4f58-968d-86655b4d2ce9\2.164.0\cmdline.ps1.
2020-03-04T17:48:48.4203824Z ##[section]Finishing: Command Line Script

i am blocked at this point and unable to move ahead. can you please help ?

thanks.

Please first fix your formatting, your post is unreadable.

  1. i used ps script to create the xml file.
$tool= Get-ChildItem -Path '(Agent.ToolsDirectory)\VsTest\16.5.0\x64\tools\net451\Team Tools\Dynamic Code Coverage Tools’ -Filter CodeCoverage.exe -Recurse -ErrorAction SilentlyContinue -Force

$parameter1 = ‘analyze’
parameter2 = '/output: (Agent.BuildDirectory)\TestResults\TestCoverage.coveragexml’
parameter3 = '(Agent.BuildDirectory)\TestResults\TestCoverage.coverage’
$parameters= “$parameter1 $parameter2 $parameter3”

Write-Host “Executing $tool $parameters”
$parms = $parameters.Split(" ")
& $tool $parms

i get the below error:

Generating script.
========================== Starting Command Output ===========================
##[command]"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'E:\vsts-agent-win-x86-2.147.1\_work\_temp\526b950f-0208-4e54-b6eb-cbce3d579cfe.ps1'"
Executing  analyze /output:E:\vsts-agent-win-x86-2.147.1\_work\192\TestResults\TestCoverage.xml E:\vsts-agent-win-x86-2.147.1\_work\192\TestResults\TestCoverage.coverage
The expression after '&' in a pipeline element produced an object that was not 
valid. It must result in a command name, a script block, or a CommandInfo 
object.
At E:\vsts-agent-win-x86-2.147.1\_work\_temp\526b950f-0208-4e54-b6eb-cbce3d579c
fe.ps1:12 char:3
+ & $tool $parms
+   ~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], ParentContainsErrorRec 
   ordException
    + FullyQualifiedErrorId : BadExpression
 
##[error]PowerShell exited with code '1'.
##[section]Finishing: PowerShell Script to create xml file
  1. i also tried the above using commandline as outlined here.
“(Agent.ToolsDirectory)\VsTest\16.5.0\x64\tools\net451\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe" analyze /output: "(Agent.BuildDirectory)\TestResults\TestCoverage.coveragexml” “$(Agent.BuildDirectory)\TestResults\TestCoverage.coverage” /verbose

when run thro command line: it gives me a different error, demanding a usage:

2020-03-04T17:48:48.3038110Z ========================== Starting Command Output ===========================
2020-03-04T17:48:48.3134276Z ##[debug]Entering Invoke-VstsTool.
2020-03-04T17:48:48.3232964Z ##[debug] Arguments: ‘/D /E:ON /V:OFF /S /C “CALL “F:\vsts-agent-win-x64-2.149.2_work_temp\b4a26cc7-572f-4977-9f2c-8e999fba30ce.cmd””’
2020-03-04T17:48:48.3250081Z ##[debug] FileName: ‘C:\Windows\system32\cmd.exe’
2020-03-04T17:48:48.3267810Z ##[debug] WorkingDirectory: ‘F:\vsts-agent-win-x64-2.149.2_work\1\s\WrittenNotificationServices\src’
2020-03-04T17:48:48.3315354Z ##[command]“C:\Windows\system32\cmd.exe” /D /E:ON /V:OFF /S /C “CALL “F:\vsts-agent-win-x64-2.149.2_work_temp\b4a26cc7-572f-4977-9f2c-8e999fba30ce.cmd””
2020-03-04T17:48:48.3408923Z “what is CD…” F:\vsts-agent-win-x64-2.149.2_work\1\s\WrittenNotificationServices\src
2020-03-04T17:48:48.3504864Z M i c r o s o f t ( R ) C o v e r a g e C o l l e c t i o n T o o l V e r s i o n 1 6 . 0 . 3 0 3 1 9 . 0
2020-03-04T17:48:48.3505933Z
2020-03-04T17:48:48.3505998Z
2020-03-04T17:48:48.3506120Z C o p y r i g h t ( c ) M i c r o s o f t C o r p o r a t i o n . A l l r i g h t s r e s e r v e d .
2020-03-04T17:48:48.3506209Z
2020-03-04T17:48:48.3506266Z
2020-03-04T17:48:48.3506337Z
2020-03-04T17:48:48.3506410Z
2020-03-04T17:48:48.3506506Z
2020-03-04T17:48:48.3506562Z
2020-03-04T17:48:48.3506650Z U s a g e : C o d e C o v e r a g e < c o m m a n d >
2020-03-04T17:48:48.3506731Z
2020-03-04T17:48:48.3506786Z
2020-03-04T17:48:48.3506856Z
2020-03-04T17:48:48.3506910Z
2020-03-04T17:48:48.3506965Z
2020-03-04T17:48:48.3507035Z
2020-03-04T17:48:48.3507151Z C o l l e c t c o v e r a g e d a t a t o t h e g i v e n c o v e r a g e f i l e .
2020-03-04T17:48:48.3507227Z
2020-03-04T17:48:48.3507282Z
2020-03-04T17:48:48.3507386Z U s a g e : c o l l e c t [ o p t i o n s ] [ c o m m a n d l i n e ]
2020-03-04T17:48:48.3507463Z
2020-03-04T17:48:48.3507526Z
2020-03-04T17:48:48.3507603Z O p t i o n s :
2020-03-04T17:48:48.3507664Z
2020-03-04T17:48:48.3507718Z
2020-03-04T17:48:48.3507808Z / c o n f i g : < p a t h >
2020-03-04T17:48:48.3507870Z
2020-03-04T17:48:48.3507936Z
2020-03-04T17:48:48.3508079Z [ o p t i o n a l ] O v e r r i d e d e f a u l t c o n f i g u r a t i o n w i t h c o n f i g u r a t i o n f i l e
2020-03-04T17:48:48.3508159Z
2020-03-04T17:48:48.3508215Z
2020-03-04T17:48:48.3508289Z s p e c i f i e d .
2020-03-04T17:48:48.3508363Z
2020-03-04T17:48:48.3508418Z
2020-03-04T17:48:48.3508472Z
2020-03-04T17:48:48.3508538Z
2020-03-04T17:48:48.3508591Z
2020-03-04T17:48:48.3508669Z / I I S
2020-03-04T17:48:48.3508730Z
2020-03-04T17:48:48.3508784Z
2020-03-04T17:48:48.3508926Z [ o p t i o n a l ] C o l l e c t c o d e c o v e r a g e f o r w e b a p p l i c a t i o n s r u n n i n g
2020-03-04T17:48:48.3509000Z
2020-03-04T17:48:48.3509064Z
2020-03-04T17:48:48.3509196Z u n d e r I n t e r n e t I n f o r m a t i o n S e r v i c e ( I I S ) . I I S W o r k e r p r o c e s s
2020-03-04T17:48:48.3509272Z
2020-03-04T17:48:48.3509335Z
2020-03-04T17:48:48.3509477Z ( w 3 w p . e x e ) w i l l b e r e g i s t e r e d f o r c o l l e c t i o n a n d a l l t h e a p p l i c a t i o n
2020-03-04T17:48:48.3509557Z
2020-03-04T17:48:48.3509612Z
2020-03-04T17:48:48.3509714Z p o o l s w i l l b e r e s t a r t e d .
2020-03-04T17:48:48.3509778Z
2020-03-04T17:48:48.3509833Z
2020-03-04T17:48:48.3509897Z
2020-03-04T17:48:48.3510013Z
2020-03-04T17:48:48.3510124Z
2020-03-04T17:48:48.3510206Z / o u t p u t : < p a t h >
2020-03-04T17:48:48.3510268Z
2020-03-04T17:48:48.3510339Z
2020-03-04T17:48:48.3510520Z [ r e q u i r e d ] T h e f i l e t o o u t p u t c o v e r a g e d a t a t o .
2020-03-04T17:48:48.3510598Z
2020-03-04T17:48:48.3510653Z
2020-03-04T17:48:48.3510716Z
2020-03-04T17:48:48.3510770Z
2020-03-04T17:48:48.3510836Z
2020-03-04T17:48:48.3510917Z / s e s s i o n : < n a m e >
2020-03-04T17:48:48.3511123Z
2020-03-04T17:48:48.3511196Z
2020-03-04T17:48:48.3511331Z [ o p t i o n a l ] T h e n a m e f o r t h e s e s s i o n . I f a s e s s i o n n a m e i s n o t
2020-03-04T17:48:48.3511488Z
2020-03-04T17:48:48.3511561Z
2020-03-04T17:48:48.3511677Z p r o v i d e d , a u n i q u e s e s s i o n n a m e w i l l b e u s e d
2020-03-04T17:48:48.3511759Z
2020-03-04T17:48:48.3511814Z
2020-03-04T17:48:48.3511883Z
2020-03-04T17:48:48.3511937Z
2020-03-04T17:48:48.3511990Z
2020-03-04T17:48:48.3512075Z / v e r b o s e
2020-03-04T17:48:48.3512134Z
2020-03-04T17:48:48.3512550Z
2020-03-04T17:48:48.3512694Z [ o p t i o n a l ] T u r n o n p r i n t i n g o f d i a g n o s t i c i n f o r m a t i o n d u r i n g r u n t i m e .
2020-03-04T17:48:48.3512775Z
2020-03-04T17:48:48.3512831Z
2020-03-04T17:48:48.3512885Z
2020-03-04T17:48:48.3512956Z
2020-03-04T17:48:48.3513009Z
2020-03-04T17:48:48.3513075Z E x a m p l e :
2020-03-04T17:48:48.3513145Z
2020-03-04T17:48:48.3513199Z
2020-03-04T17:48:48.3513353Z C o d e C o v e r a g e c o l l e c t / I I S / s e s s i o n : W e b S e s s i o n / o u t p u t : M y W e b A p p . c o v e r a g e
2020-03-04T17:48:48.3513422Z
2020-03-04T17:48:48.3513488Z
2020-03-04T17:48:48.3513543Z
2020-03-04T17:48:48.3513653Z S h u t d o w n a l o g g e r w i t h a g i v e n s e s s i o n n a m e .
2020-03-04T17:48:48.3513727Z
2020-03-04T17:48:48.3513782Z
2020-03-04T17:48:48.3513881Z U s a g e : s h u t d o w n [ o p t i o n s ]
2020-03-04T17:48:48.3513951Z
2020-03-04T17:48:48.3514005Z
2020-03-04T17:48:48.3514082Z O p t i o n s :
2020-03-04T17:48:48.3514141Z
2020-03-04T17:48:48.3514204Z
2020-03-04T17:48:48.3514285Z / s e s s i o n : < n a m e >
2020-03-04T17:48:48.3514353Z
2020-03-04T17:48:48.3514417Z
2020-03-04T17:48:48.3514534Z [ r e q u i r e d ] T h e n a m e o f t h e s e s s i o n t o s h u t d o w n
2020-03-04T17:48:48.3514609Z
2020-03-04T17:48:48.3514664Z
2020-03-04T17:48:48.3514718Z
2020-03-04T17:48:48.3514781Z
2020-03-04T17:48:48.3514834Z
2020-03-04T17:48:48.3514912Z E x a m p l e :
2020-03-04T17:48:48.3514970Z
2020-03-04T17:48:48.3515024Z
2020-03-04T17:48:48.3515146Z C o d e C o v e r a g e s h u t d o w n / s e s s i o n : W e b S e s s i o n
2020-03-04T17:48:48.3515210Z
2020-03-04T17:48:48.3515274Z
2020-03-04T17:48:48.3515327Z
2020-03-04T17:48:48.3515461Z A n a l y z e d a t a f r o m o n e o r m o r e c o v e r a g e f i l e s a n d o u t p u t X M L .
2020-03-04T17:48:48.3515538Z
2020-03-04T17:48:48.3515592Z
2020-03-04T17:48:48.3515716Z U s a g e : a n a l y z e [ o p t i o n s ] < f i l e 1 > [ f i l e 2 [ . . . ] ]
2020-03-04T17:48:48.3515788Z
2020-03-04T17:48:48.3515842Z
2020-03-04T17:48:48.3515921Z O p t i o n s :
2020-03-04T17:48:48.3515980Z
2020-03-04T17:48:48.3516045Z
2020-03-04T17:48:48.3516137Z / i n c l u d e _ s k i p p e d _ f u n c t i o n s
2020-03-04T17:48:48.3516200Z
2020-03-04T17:48:48.3516267Z
2020-03-04T17:48:48.3516390Z [ o p t i o n a l ] I n c l u d e s s k i p p e d f u n c t i o n s i n t h e r e s u l t s .
2020-03-04T17:48:48.3516466Z
2020-03-04T17:48:48.3516520Z
2020-03-04T17:48:48.3516585Z
2020-03-04T17:48:48.3516639Z
2020-03-04T17:48:48.3516692Z
2020-03-04T17:48:48.3516801Z / i n c l u d e _ s k i p p e d _ m o d u l e s
2020-03-04T17:48:48.3516865Z
2020-03-04T17:48:48.3516928Z
2020-03-04T17:48:48.3517048Z [ o p t i o n a l ] I n c l u d e s s k i p p e d m o d u l e s i n t h e r e s u l t s
2020-03-04T17:48:48.3517192Z
2020-03-04T17:48:48.3517267Z
2020-03-04T17:48:48.3517321Z
2020-03-04T17:48:48.3517388Z
2020-03-04T17:48:48.3517441Z
2020-03-04T17:48:48.3517522Z / o u t p u t : < p a t h >
2020-03-04T17:48:48.3517593Z
2020-03-04T17:48:48.3517648Z
2020-03-04T17:48:48.3517790Z [ o p t i o n a l ] T h e f i l e t o o u t p u t t h e a n a l y z e d c o v e r a g e d a t a t o
2020-03-04T17:48:48.3517857Z
2020-03-04T17:48:48.3517911Z
2020-03-04T17:48:48.3518025Z T h e d e f a u l t i s t o u s e s t a n d a r d o u t p u t
2020-03-04T17:48:48.3518090Z
2020-03-04T17:48:48.3518155Z
2020-03-04T17:48:48.3518267Z
2020-03-04T17:48:48.3518321Z
2020-03-04T17:48:48.3518390Z
2020-03-04T17:48:48.3518472Z / t e s t : < t e s t i d >
2020-03-04T17:48:48.3518545Z
2020-03-04T17:48:48.3518601Z
2020-03-04T17:48:48.3518731Z [ o p t i o n a l ] T h e t e s t i d e n t i f i e r s t r i n g t o l i m i t t h e c o v e r a g e
2020-03-04T17:48:48.3518821Z
2020-03-04T17:48:48.3518876Z
2020-03-04T17:48:48.3519021Z d a t a t o . T h i s o p t i o n c a n b e s p e c i f i e d m u l t i p l e t i m e s t o m e r g e
2020-03-04T17:48:48.3519088Z
2020-03-04T17:48:48.3519157Z
2020-03-04T17:48:48.3519267Z c o v e r a g e d a t a f o r d i f f e r e n t t e s t s t o g e t h e r
2020-03-04T17:48:48.3519332Z
2020-03-04T17:48:48.3519398Z
2020-03-04T17:48:48.3519451Z
2020-03-04T17:48:48.3519515Z
2020-03-04T17:48:48.3519570Z
2020-03-04T17:48:48.3519636Z E x a m p l e :
2020-03-04T17:48:48.3519711Z
2020-03-04T17:48:48.3519766Z
2020-03-04T17:48:48.3519894Z C o d e C o v e r a g e a n a l y z e / i n c l u d e _ s k i p p e d _ f u n c t i o n s
2020-03-04T17:48:48.3519960Z
2020-03-04T17:48:48.3520014Z
2020-03-04T17:48:48.3520162Z / i n c l u d e _ s k i p p e d _ m o d u l e s / o u t p u t : r e s u l t s . x m l M y W e b A p p . c o v e r a g e
2020-03-04T17:48:48.3520229Z
2020-03-04T17:48:48.3560738Z ##[debug]Exit code: -1
2020-03-04T17:48:48.3595746Z ##[debug]Leaving Invoke-VstsTool.
2020-03-04T17:48:48.3840149Z ##[error]Cmd.exe exited with code ‘-1’.
2020-03-04T17:48:48.3840701Z ##[debug]Processed: ##vso[task.logissue type=error]Cmd.exe exited with code ‘-1’.
2020-03-04T17:48:48.3953612Z ##[debug]Processed: ##vso[task.complete result=Failed]Error detected
2020-03-04T17:48:48.3975409Z ##[debug]Leaving F:\vsts-agent-win-x64-2.149.2_work_tasks\CmdLine_d9bafed4-0b18-4f58-968d-86655b4d2ce9\2.164.0\cmdline.ps1.
2020-03-04T17:48:48.4203824Z ##[section]Finishing: Command Line Script

i am blocked at this point and unable to move ahead. can you please help ?

And btw, i am using a .net core project. I also see the codecoverage.exe file on the path specified.(refer attachment).

and these are my build steps.

hope these help as well. looking forward to your valuable guidance.

Hi,

I see an update regardind the question of the topics here where the issue is closed Give the user the ability to provide its own CodeCoverage.exe path · Issue #798 · SonarSource/sonar-scanner-msbuild · GitHub
Detect and take VsTestToolsInstallerInstalledToolLocation environment… by mickael-caro-sonarsource · Pull Request #903 · SonarSource/sonar-scanner-msbuild · GitHub

But even with this fix, just using Test Platform, its not working

any ideas ?
Thank for your help

I solved this by moving the VisualStudioTestPlatformInstaller task before the SonarCloudPrepare task.

After this change the Analysis output was:

Attempting to locate the CodeCoverage.exe tool...
VsTestToolsInstallerInstalledToolLocation environment variable detected, seeking for CodeCoverage.exe location...
VsTestToolsInstallerInstalledToolLocation environment variable doesn't contain full path to CodeCoverage.exe tool, seeking in standard place set by VSTestPlatformToolInstaller...
CodeCoverage.exe found at C:\agents\_work\_tool\VsTest\17.1.0\x64\tools\net451\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe.
Code coverage command line tool: C:\agents\_work\_tool\VsTest\17.1.0\x64\tools\net451\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe

And coverage was displayed in SonarCloud.

More or less my .yaml:

steps:
  - task: VisualStudioTestPlatformInstaller@1
    displayName: Install Visual Studio TestPlatform
    inputs:
      versionSelector: latestStable

  - task: SonarCloudPrepare@1
    displayName: Prepare SonarQube Analysis
    inputs:
      SonarCloud: SonarCloud
      organization: xxx
      scannerMode: MSBuild
      projectKey: my_project
      projectName: my/project
      projectVersion: 1.0
      extraProperties: |
          sonar.exclusions=**/obj/**,**/*.dll,**/*.xml
          sonar.cs.nunit.reportsPaths=$(Agent.TempDirectory)/*.trx

  - task: DotNetCoreCLI@2
    displayName: "dotnet restore"
    inputs:
      command: restore
      projects: my/project
      feedsToUse: config
      nugetConfigPath: Nuget.Config

  - task: DotNetCoreCLI@2
    displayName: 'dotnet build'
    inputs:
      projects: my/project
      arguments: '--configuration debug'

  - task: DotNetCoreCLI@2
    displayName: dotnet test
    inputs:
      command: test
      projects: my/testproject
      arguments: --configuration debug /p:CollectCoverage=true /p:CoverletOutputFormat=opencover --logger trx --results-directory $(Agent.TempDirectory) --collect "Code coverage" --no-build 

  - task: SonarCloudAnalyze@1
    displayName: Run SonarQube Analysis

  - task: SonarCloudPublish@1
    displayName: Publish SonarQube Results

Coverage is then displayed in Azure Devops:
image

And in SonarCloud:
image

1 Like

This seems to have broken after an update to the SonarCloudPrepare@1 task.

I ‘fixed’ this by using an older version of the Visual Studio Test Platform Installer:

  - task: VisualStudioTestPlatformInstaller@1
    displayName: Install Visual Studio TestPlatform
    inputs:
      versionSelector: specificVersion
      testPlatformVersion: 17.3.2

Interested to hear if there is a real fix to this problem instead of my workaround.

Here is the bugreport:

Here is the fix:

But I can’t figure out how to get the fix :slight_smile:

Hello @Vincent_Meijer - yesterday we deployed an update to the DevOps extension, it should have fixed the issue.

Could you please test this on your side?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.