How to pass in Source Directory for Code Coverage

Hi,

I am using the following code:

  - task: SonarQubePrepare@4
    condition: eq(variables['Build.SourceBranchName'], 'master')
    inputs:
      SonarQube: 'SonarQube-Services-Demo'
      scannerMode: 'MSBuild'
      configMode: 'manual'
      projectKey: 'SONAR-DEMO'
      extraProperties: |
        sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)\**\*.trx
        sonar.cs.vscoveragexml.reportsPaths=$(Agent.TempDirectory)\**\*.coveragexml
  - task: DotNetCoreCLI@2
    condition: eq(variables['Build.SourceBranchName'], 'master')
    displayName: "SonarQube Collect Code Coverage"
    inputs:
      command: 'test'
      arguments: '--collect "Code Coverage"'

On run, an error is recorded:

/usr/bin/dotnet test --logger trx --results-directory /azp/agent/_work/_temp --collect Code Coverage
MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file.
##[debug]Exit code 1 received from tool '/usr/bin/dotnet'
##[debug]STDIO streams have closed for tool '/usr/bin/dotnet'
##[error]Error: The process '/usr/bin/dotnet' failed with exit code 1

I use azure do the directory the information was pulled and compiled is a working directory:

/azp/agent/_work/10/s/source

How can i get Sonar to run the dotnet test in this folder?

Thanks

I think I have resolved the initial issue with:

  - task: DotNetCoreCLI@2
    condition: eq(variables['Build.SourceBranchName'], 'master')
    displayName: "SonarQube Collect Code Coverage"
    inputs:
      command: 'test'
      projects: '**/*[Tt]ests/*.csproj'
      arguments: '--collect "Code Coverage"'

However, i get the following error message in Azure:

Data collector 'Code Coverage' message: No code coverage data available. Code coverage is currently supported only on Windows..

We get the above, due to using Linux build agents. Any advice (other than use Windows build agents)

@JayBird that message is coming from dotnet test, not from SonarQube or the Scanner. The Sonar extension doesn’t execute the tests or create the coverage files - it just imports coverage files that have been created by other tools.

coverlet is one cross-platform .NET code coverage tool, and the Sonar extension is able to import coverlet reports.

The MS documentation have more information on using coverlet.

You might find our code coverage troubleshooting guide useful too.