Sonarqube vsts task exception on coverage for .net core 2 app

安稳与你 提交于 2019-12-08 05:04:41

问题


I believe this is more a bug report than a support question, but may be i can workaround it.

I am building & testing a .net core 2 app:

the vstest step is configured as below:

A trx file and a binary .coverage files are produced.

If Code coverage checkbox is disabled, build works. If enabled like in the picture it fails with the following error:

SonarQube Scanner for MSBuild 3.0.2
Default properties file was found at C:\agent\_work\_tasks\SonarQubeScannerMsBuildBegin_15b84ca1-b62f-4a2a-a403-89b77a063157\3.0.2\SonarQubeScannerMsBuild\SonarQube.Analysis.xml
Loading analysis properties from C:\agent\_work\_tasks\SonarQubeScannerMsBuildBegin_15b84ca1-b62f-4a2a-a403-89b77a063157\3.0.2\SonarQubeScannerMsBuild\SonarQube.Analysis.xml
Post-processing started.
13:15:00.927  Loading the SonarQube analysis config from C:\agent\_work\3\.sonarqube\conf\SonarQubeAnalysisConfig.xml
13:15:00.927  TeamBuild environment detected
13:15:00.927  Analysis base directory: C:\agent\_work\3\.sonarqube
Build directory: C:\agent\_work\3
Bin directory: C:\agent\_work\3\.sonarqube\bin
Config directory: C:\agent\_work\3\.sonarqube\conf
Output directory: C:\agent\_work\3\.sonarqube\out
Config file: C:\agent\_work\3\.sonarqube\conf\SonarQubeAnalysisConfig.xml
13:15:00.927  Attempting to locate the CodeCoverage.exe tool...
13:15:00.942  Attempting to locate the CodeCoverage.exe tool using setup configuration...
13:15:00.958  Code coverage command line tool: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
13:15:00.958  Fetching code coverage report information from TFS...
13:15:00.958  Attempting to locate a test results (.trx) file...
13:15:00.989  Looking for TRX files in: C:\agent\_work\3\TestResults, C:\agent\_work\3\s\TestResults
13:15:00.989  Located a test results file: C:\agent\_work\3\s\TestResults\XYZBuild_PRODUCT_XYZ_2017-09-29_13_14_52.trx
13:15:00.989  One code coverage attachment was found in the trx file: PRODUCT_XYZ\XYZBuild_PRODUCT_XYZ 2017-09-29 13_14_45.coverage
13:15:00.989  Absolute path to coverage file: C:\agent\_work\3\s\TestResults\XYZBuild_PRODUCT_XYZ_2017-09-29_13_14_52\In\PRODUCT_XYZ\XYZBuild_PRODUCT_XYZ 2017-09-29 13_14_45.coverage
Unhandled Exception: System.ComponentModel.Win32Exception: The directory name is invalid
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at SonarQube.Common.ProcessRunner.Execute(ProcessRunnerArguments runnerArgs)
at SonarQube.TeamBuild.Integration.CoverageReportConverter.ConvertBinaryToXml(String converterExeFilePath, String inputBinaryFilePath, String outputXmlFilePath, ILogger logger)
at SonarQube.TeamBuild.Integration.CoverageReportConverter.ConvertToXml(String inputFilePath, String outputFilePath, ILogger logger)
at SonarQube.TeamBuild.Integration.CoverageReportProcessorBase.ProcessBinaryCodeCoverageReport(String binaryCoverageFilePath)
at SonarQube.TeamBuild.Integration.CoverageReportProcessorBase.ProcessCoverageReports()
at SonarQube.TeamBuild.PostProcessor.CoverageReportProcessor.ProcessCoverageReports()
at SonarQube.TeamBuild.PostProcessor.MSBuildPostProcessor.Execute(String[] args, AnalysisConfig config, ITeamBuildSettings settings)
at SonarQube.Bootstrapper.BootstrapperClass.PostProcess()
at SonarQube.Bootstrapper.BootstrapperClass.Execute()
at SonarQube.Bootstrapper.Program.Execute(String[] args, ILogger logger)
at SonarQube.Bootstrapper.Program.Main(String[] args)
at SonarQube.Old.Bootstrapper.Program.Main(String[] args)
System.Exception: Unexpected exit code received from batch file: 255
Processed: ##vso[task.logissue type=error;]System.Exception: Unexpected exit code received from batch file: 255
   at Microsoft.TeamFoundation.DistributedTask.Task.Internal.InvokeBatchScriptCmdlet.ProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()
The build was not triggered by a Pull Request, not processing code analysis comments
Invoke - Get-TaskVariable cmdlet
Variable read: MSBuild.SonarQube.Internal.IncludeFullReport = true
Invoke - Get-TaskVariable cmdlet
Variable read: MSBuild.SonarQube.Internal.ServerVersion =
Calling InvokeGetRestMethod "/api/server/version"
Invoke - Get-TaskVariable cmdlet
Variable read: MSBuild.SonarQube.HostUrl = https://sonarqube.test.domain.com/
Invoke - Get-TaskVariable cmdlet
Variable read: MSBuild.SonarQube.ServerUsername = ********
Invoke - Get-TaskVariable cmdlet
Variable read: MSBuild.SonarQube.ServerPassword =
GET https://sonarqube.test.domain.com/api/server/version with 0-byte payload
received 5-byte response of content type text/html;charset=utf-8
Processed: ##vso[task.setvariable variable=MSBuild.SonarQube.Internal.ServerVersion;]5.6.6
The SonarQube server version is 5.6.6
Waiting on the SonarQube server to finish processing in order to determine the quality gate status.
Invoke - Get-TaskVariable cmdlet
Variable read: Agent.BuildDirectory = C:\agent\_work\3
Could not find the task details file at C:\agent\_work\3\.sonarqube\out\.sonar\report-task.txt
System.Management.Automation.RuntimeException: Cannot determine if the analysis has finished. Possible cause: your SonarQube server version is lower than 5.3 - for more details see https://go.microsoft.com/fwlink/?LinkId=722407 ---> System.Management.Automation.RuntimeException: Cannot determine if the analysis has finished. Possible cause: your SonarQube server version is lower than 5.3 - for more details see https://go.microsoft.com/fwlink/?LinkId=722407
Processed: ##vso[task.logissue type=error;]System.Management.Automation.RuntimeException: Cannot determine if the analysis has finished. Possible cause: your SonarQube server version is lower than 5.3 - for more details see https://go.microsoft.com/fwlink/?LinkId=722407 ---> System.Management.Automation.RuntimeException: Cannot determine if the analysis has finished. Possible cause: your SonarQube server version is lower than 5.3 - for more details see https://go.microsoft.com/fwlink/?LinkId=722407
   --- End of inner exception stack trace ---
   at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
   at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
   at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
   at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
   at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
   at Microsoft.TeamFoundation.DistributedTask.Handlers.LegacyVSTSPowerShellHost.VSTSPowerShellHost.Main(String[] args)
LegacyVSTSPowerShellHost.exe completed with return code: -1.

I tried to call the CodeCoverage.exe tool manually with what i believe are the parameters teh scanner is using, and it creates the xml file correctly.

Finally, I cannot create an issue here: https://github.com/SonarSource/sonar-scanner-msbuild so i assume it will be rerouted from here.

来源:https://stackoverflow.com/questions/46526922/sonarqube-vsts-task-exception-on-coverage-for-net-core-2-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!