No coveragexml files in Scanner for MSBuild through VSTS extension - tfs

Using:
TFS 2017 Update-2
VS2015
VSTS Task 3.2.0
SonarQube 5.6.6 LTS
After the upgrade of the SonarQube Extension from 4.0.2 to 4.1 We get a warning when running the "Scanner for MSBuild - End Analysis" task.
We noticed that the codecoverage.xml files are not generated by the Code Coverage Tool (see logging below).
This only appears for TFS agents with VS2015 installed, it works fine for the same setup with VS2017.
We applied the work-around: SonarQube Code Coverage from VSTS
we put /d:sonar.cs.vscoveragexml.reportsPaths=**/*.coveragexml in the additional setting of the task "Scanner for MSBuild - Begin Analysis"
But stil no codecoverage.xmlfiles are produced
Is there another workaround or solution ?
2018-03-21T10:01:20.7772938Z ##[section]Starting: Complete the SonarQube analysis
2018-03-21T10:01:20.7929236Z ==============================================================================
2018-03-21T10:01:20.7929236Z Task : Scanner for MSBuild - End Analysis
2018-03-21T10:01:20.7929236Z Description : [DEPRECATED] Use new version of the task
2018-03-21T10:01:20.7929236Z Version : 3.2.0
2018-03-21T10:01:20.7929236Z Author : SonarSource
2018-03-21T10:01:20.7929236Z Help : [More Information](http://redirect.sonarsource.com/doc/install-configure-scanner-tfs-ts.html)
2018-03-21T10:01:20.7929236Z ==============================================================================
2018-03-21T10:01:20.7929236Z Preparing task execution handler.
2018-03-21T10:01:21.1835551Z Executing the powershell script: C:\TFS\Agent\_work\_tasks\SonarQubeScannerMsBuildEnd_6d01813a-9589-4b15-8491-8164aeb38055\3.2.0\SonarQubePostTest.ps1
2018-03-21T10:01:22.3867151Z WARNING: ------------------------------------------------------------------------
2018-03-21T10:01:22.3867151Z This executable is deprecated and may be removed in next major version of the SonarScanner for MSBuild. Please use 'SonarScanner.MSBuild.exe' instead.
2018-03-21T10:01:22.3867151Z ------------------------------------------------------------------------
2018-03-21T10:01:22.3867151Z SonarScanner for MSBuild 4.1
2018-03-21T10:01:22.3867151Z Using the .NET Framework version of the Scanner for MSBuild
2018-03-21T10:01:22.3867151Z Default properties file was found at C:\TFS\Agent\_work\_tasks\SonarQubeScannerMsBuildBegin_15b84ca1-b62f-4a2a-a403-89b77a063157\3.2.0\SonarQubeScannerMsBuild\SonarQube.Analysis.xml
2018-03-21T10:01:22.3867151Z Loading analysis properties from C:\TFS\Agent\_work\_tasks\SonarQubeScannerMsBuildBegin_15b84ca1-b62f-4a2a-a403-89b77a063157\3.2.0\SonarQubeScannerMsBuild\SonarQube.Analysis.xml
2018-03-21T10:01:22.3867151Z Post-processing started.
2018-03-21T10:01:22.3867151Z 11:01:21.761 11:01:21.746 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.

This issue is being tracked in #461 Failure to find VS2015 CodeCoverage.exe after searching for nonexistent registry key which lists the known workarounds (namely, manually add a registry key, or use VS2017 to build).
It should also work if the build agents have both VS2015 and VS2017 installed - the build can be performed using VS2015, but scanner end step should detect and use the VS2017 version of the code coverage tool.

Related

SonarScanner giving 'MsBuild.exe' is not recognized as an internal or external command on TFS 2018

I'm adding SonarQube to existing TFS 2018 builds. I was following the directions for downloading Community Edition 7.4 located here https://docs.sonarqube.org/display/SCAN/Install+the+SonarScanner+for+MSBuild.
Going through the steps of the Quick Installation Guide https://docs.sonarqube.org/latest/setup/get-started-2-minutes/
I get to the part where I’m asked to “Execute the Scanner for MSBuild from your computer” using the below commands:
SonarScanner.MSBuild.exe begin /k:"{key}" /d:sonar.host.url="http://localhost:9000" /d:sonar.login="{key}"
MsBuild.exe /t:Rebuild
SonarScanner.MSBuild.exe end /d:sonar.login="{key}"
When I run the first command it succeeds
C:\sonar-scanner-msbuild-4.4.2.1543-net46> SonarScanner.MSBuild.exe begin /k:"{key}" /d:sonar.host.url="http://localhost:9000" /d:sonar.login="{key}"
SonarScanner for MSBuild 4.4.2
Using the .NET Framework version of the Scanner for MSBuild
Default properties file was found at C:\sonar-scanner-msbuild-4.4.2.1543-net46\SonarQube.Analysis.xml
Loading analysis properties from C:\sonar-scanner-msbuild-4.4.2.1543-net46\SonarQube.Analysis.xml
Pre-processing started.
Preparing working directories...
13:32:09.468 Updating build integration targets...
13:32:09.5 Fetching analysis configuration settings...
13:32:10.173 Provisioning analyzer assemblies for cs...
13:32:10.173 Installing required Roslyn analyzers...
13:32:10.579 Provisioning analyzer assemblies for vbnet...
13:32:10.579 Installing required Roslyn analyzers...
13:32:10.735 Pre-processing succeeded.
However when I run the second command "MsBuild.exe /t:Rebuild" It fails with the following error:
C:\Program Files (x86)>MsBuild.exe /t:Rebuild
'MsBuild.exe' is not recognized as an internal or external command,
operable program or batch file.
I confirmed I added/updated environmental variables %PATH%, MsBuild exists, I’m wondering if there’s an additional step not noted in the instructions for .NET 4.5 framework? Has anyone come across this error for .NET using TFS builds or has any thoughts?
Try to enter exact path of msbuild e.g. for VS2017 Professional command should be:
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\"MsBuild.exe /t:Rebuild

SonarQube Scanner for MS build with Jenkins failed in the end step

These are the final logs:
The SonarQube MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
Possible causes:
The project has not been built - the project must be built in between the begin and end steps
An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0 upwards are supported
The begin, build and end steps have not all been launched from the same folder
None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)
Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.

No ProjectInfo.xml files were found .TFS build with sonar end task

I am trying to configure my visual studio project to send some analysis data to SonarQube server using TFS 2015 build (vnext)
I get this error in the Sonar end task.
##[error]No ProjectInfo.xml files were found. Possible causes:
##[error]1. The project has not been built - the end step was called right after the begin step, without a build step in between
An unsupported version of MSBuild has been used to build the project. Currently MSBuild 12.0 upwards are supported
We use MSBuild 14.0 in the server.
The SonarQube Scanner for MSBuild requires your project to be built
with MSBuild 14.0. We recommend installing Visual Studio 2015 on the
analysis machine in order to benefit from the integration and features
provided with the Visual Studio ecosystem (VSTest, MSTest unit tests,
etc.).
Suggest you to also install VS2015 on your build server, and since you are using MSbuild 14.0, double check if you are using the old task with deprecated in front which used for MSbuild 12.0. SonarQube Scanner for MSBuild released with static analysis which could executed during the build on MSbuild 14.0.
The support of MSBuild 12 by the SonarQube Scanner for MSBuild is
deprecated and will be removed in a future release.
Source: Compatibility with Visual Studio and MSBuild
Please download and use the latest version of the SonarQube Scanner for MSBuild in marketplace and try again. The recent documentation is available from Analyzing with SonarQube Extension for VSTS/TFS, you could also take a look at this tutorial.

No ProjectInfo.xml files were found Sonar scan

I am trying to configure my visual studio project to send some scan data to SonarQube server using TFS 2015 build (vnext)
I get this error in the Sonar end task.
##[error]No ProjectInfo.xml files were found. Possible causes:
##[error]1. The project has not been built
The end step was called right after the begin step, without a build step in between an unsupported version of MSBuild has been used to build the project. Currently MSBuild 12.0 upwards are supported.
We use MSBuild 14.0 in the server. it is a C++ project (VCXPROJ project File)

SonarQube MSBuild scanner: How to fix MSBuild 12 / sonar-runner deprecation message

We are using Visual Studio 2015 (original release, no update) with SonarQube and Jenkins, and keep getting the message:
WARN - * The use of MSBuild 12 or the sonar-runner to analyze C# projects is DEPRECATED *
However, we are using MSBuild 14, SonarLint, and the SonarQube scanner for MSBuild. This is confirmed at the beginning of the log:
SonarQube Scanner for MSBuild Begin Step 2.0
Loading analysis properties from c:\Program Files (x86)\tools\MSBuild.SonarQube.Runner-2.1\SonarQube.Analysis.xml
15:25:15.073 Updating build integration targets...
15:25:15.079 Fetching analysis configuration settings...
15:25:15.51 Generating rulesets...
15:25:16.629 Provisioning analyzer assemblies...
15:25:16.63 Installing required Roslyn analyzers...
SonarQube Server is 5.1.2
We used the instructions at http://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+MSBuild#AnalyzingwithSonarQubeScannerforMSBuild-msbuildcompat and the Jenkins integration
http://docs.sonarqube.org/display/SCAN/From+Jenkins
I found the question SonarQube warning on MSBuild version but I think we are correctly using SonarLint. What is the cause of the deprecation message?
We finally solved this issue by updating everything: We updated the C# plugin in Sonarqube and all Jenkins Plugins (including the msbuild plugin). After that, the deprecation message no longer occurs.

Resources