1

Good day,

I followed this guide to set-up integration of Azure DevOps and SonarCloud: https://learn.microsoft.com/en-us/labs/devops/sonarcloudlab/index

Everything goes well, I was able to setup build on master branch as well as builds on PRs. One thing that was missing out of the box from this guide is sending Test Coverage results to the SonarCloud (at least for the .NET Core projects, I used ".NET Core with SonarCloud" tamplate).

I found another guide on how we could convert standart .trx report to the .xml one and upload it to the SonarCloud: https://yuriburger.net/2018/09/10/getting-coverage-reports-with-net-core/

But faced another issue with PowerShell command in AzureDevOps, it can't get a reference to the $(Agent.TempDirectory) variable during the execution: https://github.com/yuriburger/net-cover-demo/issues/1

Maybe someone faced the similar problem? Or maybe can suggest another way how I could send Test Coverage results to the SonarCloud?

Thanks!

1 Answers1

1

Because you use the PS script from a file you need to use the variable in this way:

$env:Agent.TempDirectory
Shayki Abramczyk
  • 36,824
  • 16
  • 89
  • 114
  • Sorry for bothering you, but can I ask one more question related to the PowerShell, I'm not an expert in it and I can't figure out the last piece. First script is working fine, but I have problems with the second one [link](https://github.com/yuriburger/net-cover-demo/blob/master/AnalyzeCoverageFile.ps1) The problem is with the last line, I got an error in AzureDevops _The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command 2018-10-19T14:09:49.7110197Z name, a script block, or a CommandInfo object._ `.ps1:10 char:3 + & $tool $parms` – Roman Borysenok Oct 19 '18 at 14:21
  • Maybe you could help with this also? I'll be really appreciated – Roman Borysenok Oct 19 '18 at 14:27
  • Add in the line before the last line: `Write-Output $tool` and paste here the result. – Shayki Abramczyk Oct 20 '18 at 20:51
  • Hi Shayki, thanks for your comment, $tool is empty, it can't find executable by it's path `$env:Agent.TempDirectory\VsTest\*\tools\net451\Team Tools\Dynamic Code Coverage Tools\amd64\` – Roman Borysenok Oct 22 '18 at 07:27
  • Ok, so the path is incorrect. try to `Write-Output $env:Agent.TempDirectory` to check that temp folder exists. BTW - do you use Hosted agent or Private agent? – Shayki Abramczyk Oct 22 '18 at 08:01