TFS sonar build failed with .pdb file not found - tfs

Our sonar build (XAML Build) for TFS is failing with below mentioned error
Start Sonar-runner
ERROR: Error during Sonar runner execution
ERROR: Unable to execute
Sonar ERROR: Caused by: Cannot find the .pdb file "C:\Builds\1\ABC\Sonar_t\src\NET-WIN\Order\Entry\Entryl\Loss.......\Referentials\Commercial\Rules\bin\Debug\essel.Order.Referentials.Commercial.Rules.pdb" inferred from the property "sonar.cs.fxcop.assembly".
ERROR: ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with the -e switch. ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
The project/solution was created in Visual Studio 2008 version and our build server runs Visual Studio 2015 so I pass /toolsversion:3.5 as an MSbuild argument.
Environment details
TFS 2015 update 1 (build server)
sonar version 4.5.1, sonar runner - 2.4, C# plugin 3.3
The CI build for the same solution is successful but sonar build is showing partially succeed with missing .pdb file
What could be causing this ?

Related

SonarQube build errors in TFS 2017

Currently having the following errors on the "Complete the SonarQube analysis" step of our TFS 2017 build:
2017-12-05T22:04:24.5437340Z ##[error]System.Management.Automation.CommandNotFoundException: The term 'Get-TaskVariable' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
2017-12-05T22:04:24.5837397Z ##[error]System.Management.Automation.RuntimeException: The MSBuild.SonarQube.Runner executable could not be found. Check that the build definition includes a SonarQube Pre-Build step ---> System.Management.Automation.RuntimeException: The MSBuild.SonarQube.Runner executable could not be found. Check that the build definition includes a SonarQube Pre-Build step
SonarQube version: Version 6.7 (build 33306)
SonarQube Scanner for MSBuild version: 3.0.2
The "Prepare the SonarQube Analysis" step completes prior to the Visual Studio build step with no errors.
According to the error seems SonarQube.Runner didn't captured by TFS build agent.
Double confirm the configuration in SonarQube Scanner for MSBuild - Begin Analysis task which used to prepare the analysis before executing the build. Such as SonarQube Endpoint.
Besides, on the build agent:
Make sure the .NET Framework v4.5.2+ is installed
Make sure the Java Runtime Environment 8 is installed
Source Link: Analyzing with SonarQube Extension for VSTS/TFS
Try to create a new build definition with a simple test project to see if got the same error.

How do I set Local module directory for sonar scanner for MSBuild in Jenkins?

My jenkins project does 2 checkouts, one from a framework and one from an application A that uses the framework.
I want to run a sonar scanner on application A.
I Have 6 building steps in jenkins
Execute Windows batch command : nuget.exe restore "%WORKSPACE%\Framework\branches\1.0.1.0\Framework.sln"
Execute Windows batch command : nuget.exe restore "%WORKSPACE%\AppUsingFramework\branches\v1.1.3\AppUsingFramework.sln"
Build a Visual Studio project or solution using MSBuild : build framework
SonarQube Scanner for MSBuild - Begin Analysis // HOW DO I SET THE FOLDER TO %WORKSPACE%\AppUsingFramework\branches\v1.1.3 ?
Build a Visual Studio project or solution using MSBuild : build the application
MSBuild Build File : AppUsingFramework\branches\v1.1.3\AppUsingFramework.sln
SonarQube Scanner for MSBuild - End Analysis
I get this message :
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 or end steps have not all been launched from the same folder
Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.
So I suspect that I should specify working folder (%WORKSPACE%\AppUsingFramework\branches\v1.1.3) to sonar when I start it, how do I do that ?
I use :
Jenkins 2.60.2
SonarQube Scanner for MSBuild 3.0.1.635 (install automatically from github)
MSBuild 15
By removing the unnecessary build framework step (it's built in the app already) and by only specifiying AppUsingFramework.sln without path the sonar scan succeed.

Sonarqube build for UWP-App failed

I habe a TFS-Server-Build (TFS 2017) on a Build-Agent with VS 2017. The first Buildstep (Prepare the Sonarqube analysis) and the build of the solution works fine. But i have a error at "Complete the SonarQube analysis":
2017-05-29T03:06:09.1933915Z ##[error]The SonarQube MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
2017-05-29T03:06:09.1933915Z ##[error]Possible causes:
2017-05-29T03:06:09.1933915Z ##[error]1. The project has not been built - the project must be built in between the begin and end steps
2017-05-29T03:06:09.1933915Z ##[error]2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 12.0 upwards are supported
2017-05-29T03:06:09.1933915Z ##[error]3. The begin, build or end steps have not all been launched from the same folder
2017-05-29T03:06:09.1933915Z Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.
2017-05-29T03:06:09.1933915Z ##[error]05:06:09.115 Post-processing failed. Exit code: 1
Can anyone help?
Kind regards
Sebastian
I am not familiar with TFS-Server-Build,, but the possible causes are mentioned.
Check the following link for more details on how to set it up properly
Just like the error mentioned this stands for SonarQube was unable to collect the required information about your projects
Even though you have installed MSBUILD 12 or above, you should make sure the Build agent is calling the right version.
And double check if the MSBuild.SonarQube.Runner and MSBuild is running from the same working directory. At .sonarqube/out folder the sonar-project.properties is getting created or not.

SonarQube 6.0 doesn't find project on TFS 2015

I have a ASP.Net Web Application using .Net Framework 4.5.1 and it's building on the TFS Buildserver (on premise), but SonarQube doesn't perform the analysis. All other buildsteps are successfull. SonarQube 6.0 is a fresh installation, the Runner was installed around a year ago.
The necessary .Net Frameworks for SonarQube and Builds are installed on the build machine.
On a WebAPI Project the analyzer works like a charm. What could it be?
******************************************************************************
Starting task: Fetch the Quality Profile from SonarQube
******************************************************************************
Executing the powershell script: C:\Agents\Agent1\tasks\SonarQubePreBuild\1.0.34\SonarQubePreBuild.ps1
SonarQube Scanner for MSBuild 1.1
Default properties file was not found at C:\Agents\Agent1\tasks\SonarQubePreBuild\1.0.34\MSBuild.SonarQube.Runner-1.1\SonarQube.Analysis.xml
Pre-processing started.
Preparing working directories...
Checking for updates...
SonarQube Scanner for MSBuild Begin Step 2.1
14:41:58.919 Default properties file was not found at C:\Agents\Agent1\_work\14\.sonarqube\bin\SonarQube.Analysis.xml
14:41:58.929 Updating build integration targets...
14:41:58.939 Fetching analysis configuration settings...
14:41:59.039 Generating rulesets...
14:42:00.119 Provisioning analyzer assemblies...
14:42:00.119 Installing required Roslyn analyzers...
Pre-processing succeeded.
******************************************************************************
Finishing task: SonarQubePreBuild
******************************************************************************
... building solution, publish symbols & drop ...
******************************************************************************
Starting task: Finish the analysis and upload the results to SonarQube
******************************************************************************
Executing the powershell script: C:\Agents\Agent1\tasks\SonarQubePostTest\1.0.36\SonarQubePostTest.ps1
SonarQube Scanner for MSBuild 1.1
Default properties file was not found at C:\Agents\Agent1\tasks\SonarQubePreBuild\1.0.34\MSBuild.SonarQube.Runner-1.1\SonarQube.Analysis.xml
Post-processing started.
SonarQube Scanner for MSBuild End Step 2.1
14:40:50.486 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.
The exclude flag has been set so the project will not be analyzed by SonarQube. Project file: C:\Agents\Agent1\_work\14\s\TdbWeb\TdbWeb\TdbWeb.csproj
No analysable projects were found. SonarQube analysis will not be performed. Check the build summary report for details.
Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.
14:40:50.526 Creating a summary markdown file...
Post-processing failed. Exit code: 1
Unexpected exit code received from batch file: 1
The build was not set to fail if the associated quality gate fails.
******************************************************************************
Finishing task: SonarQubePostTest
******************************************************************************
You need Visual Studio Enterprise edition for code coverage and you are using VS Pro. Have a look at this page and expand the 'tesing tools' section. Code coverage is only listed for the Enterprise edition.

Jenkins MSBuild SonarQube Runner 1.0.2 projectinfo.xml file not found

I'm having trouble running the sonarqube msbuild runner v1.0.2 in jenkins.
The build runs fine, but the plugin doesn't seem to import the sonar targets correctly.
Here's the logs when the sonar build kicks off:
[workspace] $C:\.jenkins\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\MS_Build_Runner_1.0.2\MSBuild.SonarQube.Runner.exe begin /k:my.project /n:myprojectname /v:1.0 /d:sonar.host.url=http://1.1.1.1:9000/
MSBuild SonarQube Runner Bootstrapper 1.0.2.0
Default properties file was found at C:\.jenkins\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\MS_Build_Runner_1.0.2\SonarQube.Analysis.xml
Loading analysis properties from C:\.jenkins\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\MS_Build_Runner_1.0.2\SonarQube.Analysis.xml
Pre-processing started.
Preparing working directories...
Checking for updates...
MSBuild SonarQube Runner Pre-processor 1.0.2.0
10:17:18.025 Loading analysis properties from C:\.jenkins\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\MS_Build_Runner_1.0.2\SonarQube.Analysis.xml
10:17:18.056 Updating build integration targets...
10:17:18.072 Fetching analysis configuration settings...
10:17:21.332 Generating rulesets...
Pre-processing succeeded.
Path To MSBuild.exe: C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
Executing the command cmd.exe /C " C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:Configuration=Development /t:Clean,Build /tv:14.0 /p:VisualStudioVersion=14.0 /m:1 /fl2 /flp2:verbosity=diagnostic myprojectname.sln " && exit %%ERRORLEVEL%% from C:\.jenkins\jobs\Technology - WWW - Content Store Client\workspace
[workspace] $ cmd.exe /C " C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /p:Configuration=Development /t:Clean,Build /tv:14.0 /p:VisualStudioVersion=14.0 /m:1 /fl2 /flp2:verbosity=diagnostic ContentStoreClientSolution.sln " && exit %%ERRORLEVEL%%
Microsoft (R) Build Engine version 4.6.81.0...
And here when if finishes:
[workspace] $ C:\.jenkins\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\MS_Build_Runner_1.0.2\MSBuild.SonarQube.Runner.exe end
MSBuild SonarQube Runner Bootstrapper 1.0.2.0
Default properties file was found at C:\.jenkins\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\MS_Build_Runner_1.0.2\SonarQube.Analysis.xml
Loading analysis properties from C:\.jenkins\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\MS_Build_Runner_1.0.2\SonarQube.Analysis.xml
Post-processing started.
No ProjectInfo.xml files were found. Possible causes: you specified an invalid build configuration or the custom MSBuild analysis targets were not imported.
MSBuild SonarQube Runner Post-processor 1.0.2.0
Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.
10:21:04.257 Creating a summary markdown file...
Post-processing failed. Exit code: 1
ERROR: Execution of MSBuild SonarQube Runner failed (exit code 1)
The plugin installs itself int he tools subfolder of jenkins. But, looking in the project workspace, I can see a folder called .sonar that appears to have all the correct files and targets etc in it.
Any ideas on why the build is failing?
You need to use MSBuild 12 at least (version 14, shipping with VS 2015 will give you more accurate analysis results with version 1.1 of the SonarQube Scanner for MSBuild & C# Plugin 4.4).
The ImportsBefore targets are not deployed for MSBuild 4.0 - which is why no information is being collected during your MSBuild execution. We're not going to add support for MSBuild 4.0 or earlier versions.
Note that in the upcoming SonarQube Scanner for MSBuild 1.1 version, the error message mentioning ProjectInfo.xml has been largely improved to let you know about the potential root causes: See https://jira.sonarsource.com/browse/SONARMSBRU-180

Resources