i am using visual studio 2015 and tfs for build the project,
I started the build but got stuck with the error described below,
2016-03-17T09:38:15.2135195Z ##[error]No ProjectInfo.xml files were found. Possible causes:
2016-03-17T09:38:15.2135195Z ##[error]1. The project has not been built - the end step was called right after the begin step, without a build step in between
2016-03-17T09:38:15.2135195Z ##[error]2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 12.0 upwards are supported
2016-03-17T09:38:15.2135195Z ##[error]3. The build step has been launched from a different working folder
2016-03-17T09:38:15.2135195Z Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.
2016-03-17T09:38:15.2135195Z 15:08:15.15 Creating a summary markdown file...
2016-03-17T09:38:15.2135195Z ##[error]Post-processing failed. Exit code: 1
2016-03-17T09:38:15.2135195Z ##[error]Unexpected exit code received from batch file: 1
Can any one help me in this?
Assuming you are using TFS2015 vNext build, and you are trying to add build tasks below to execute a SonarQube analysis:
· SonarQube for MSBuild – Begin Analysis
· SonarQube for MSBuild – End Analysis
From your error log, you need to make sure the End Analysis task should be used to create a step that is executed after the “Visual Studio Build” task step. Review blog Build Tasks for SonarQube Analysis get more information of how to use SonarQube analysis tasks.
Related
How do I configure the sonar to include folders or projects which are not part of the current .net solution. I have the following structure my current project:
MyProject - Root Folder
ProjectA - Normal .net project
ProjectB
MyProject.Services
MyProject.Services - This is a asp.net core project
MyProject.Services.sln
MyProject.Services.Model
MyProject.Services.Repository
MyProject.sln
folder_structure
MyProject.Services is a separate solution having .net core project. During the sonar analysis - it is only analyzing the files associated with MyProject.sln. The requirement is to include files from MyProject.Services as well to have a single report for both solutions.
I tried to include it as a parameter (sonar.sources) but got below error:
File "..." can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files
We are using a powershell script for the sonar begin/end step which is getting executed through bamboo build job.
Sonar Scanner:
C:\sonar-scanner-msbuild-4.6.0.1930-net46\SonarScanner.MSBuild.exe
Sonarqube version: 8.9
The Sonar C# and Sonar VB.NET analyzers are Roslyn analyzers, so you need to build a project/solution to get the analysis results. So, if you want issues for MyProject.Services you will have to build it.
You can include the results for multiple MSBuild projects/solutions in the same Sonar project - just build the required projects between the Scanner begin and end steps e.g.
run the scanner begin step
build MyProject.Services.sln
build MyProject.sln
run the scanner end step
I'm using VSTS hosted agent VS2017 to run the build, tests, and SonarQube analysis. I'm using the SonarQube extension from the marketplace (https://marketplace.visualstudio.com/items?itemName=SonarSource.sonarqube). Task version in use is 4 which uses SonarQube Scanner for MSBuild 4.0.2.
The analysis works well, but it doesn't translate the code coverage results to the SonarQube. I can see the Code Coverage analysis in VSTS (build details), but not in SonarQube.
In my understanding, the problem is that VSTS generates a binary file with an extension .codecoverage. SonarQube doesn't know how to handle this file. I'm having trouble converting this to XML format as it seems I have no means to do it.
Has someone used VSTS successfully with SonarQube and got the Code Coverage results to SonarQube as well? How have you set it up?
EDIT 1
SonarQube version that I'm using is: Version 6.7 (build 33306), Community Edition
EDIT 2
The end of analysis actually generates the xml-file, like was stated in the comments below. This is from the logs:
2018-03-06T11:14:56.4189055Z 11:14:56.417 Attempting to locate the
CodeCoverage.exe tool...
2018-03-06T11:14:56.4210147Z 11:14:56.42 Attempting to locate the
CodeCoverage.exe tool using setup configuration...
2018-03-06T11:14:56.4345085Z 11:14:56.433 Code coverage command line tool:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Team
Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
2018-03-06T11:14:56.4349101Z 11:14:56.434 Fetching code coverage report
information from TFS...
2018-03-06T11:14:56.4363869Z 11:14:56.435 Attempting to locate a test
results (.trx) file...
2018-03-06T11:14:57.0458245Z 11:14:57.044 Looking for TRX files in:
D:\a\1\TestResults, D:\a\1\s\TestResults
2018-03-06T11:14:57.0462747Z 11:14:57.045 Located a test results file:
D:\a\1\s\TestResults\VssAdministrator_factoryvm-az436_2018-03-
06_11_13_09.trx
2018-03-06T11:14:57.0600587Z 11:14:57.059 One code coverage attachment was
found in the trx file: factoryvm-az436\VssAdministrator_factoryvm-az436
2018-03-06 11_11_34.coverage
2018-03-06T11:14:57.0602504Z 11:14:57.059 Absolute path to coverage file:
D:\a\1\s\TestResults\VssAdministrator_factoryvm-az436_2018-03-
06_11_13_09\In\factoryvm-az436\VssAdministrator_factoryvm-az436 2018-03-06
11_11_34.coverage
2018-03-06T11:14:57.0691948Z 11:14:57.068 Executing file C:\Program Files
(x86)\Microsoft Visual Studio\2017\Enterprise\Team Tools\Dynamic Code
Coverage Tools\CodeCoverage.exe
2018-03-06T11:14:57.0692731Z Args: analyze
/output:D:\a\1\s\TestResults\VssAdministrator_factoryvm-az436_2018-03-
06_11_13_09\In\factoryvm-az436\VssAdministrator_factoryvm-az436 2018-03-06
11_11_34.coveragexml D:\a\1\s\TestResults\VssAdministrator_factoryvm-
az436_2018-03-06_11_13_09\In\factoryvm-az436\VssAdministrator_factoryvm-
az436 2018-03-06 11_11_34.coverage
2018-03-06T11:14:57.0694963Z Working directory:
D:\a\1\s\TestResults\VssAdministrator_factoryvm-az436_2018-03-
06_11_13_09\In\factoryvm-az436
2018-03-06T11:14:57.0695792Z Timeout (ms):60000
2018-03-06T11:14:57.0699007Z Process id: 3540
2018-03-06T11:14:58.7847582Z 11:14:58.783 Process returned exit code 0
2018-03-06T11:14:58.7858908Z 11:14:58.784 Updating project info files with
code coverage information...
The VSTS extension should automatically import the coverage results, but there is currently a regression that will be fixed (hopefully) soon: SONARMSBRU-339
Meanwhile, there is a workaround explained in the VSTS extension documentation in "Analysing a .NET solution": in the Additional Properties text area, add the following property:
sonar.cs.vscoveragexml.reportsPaths=**/*.coveragexml
I was unable to see the 'coveragexml' file even though I set 'sonar.verbose=true', 'system.debug=true'. Although, I found another way that works just fine, i.e. converting '.coverage' files into '.coveragexml' with PowerShell script:
Get-ChildItem -Path $(Agent.TempDirectory) -Include "*.coverage" -File -Recurse | % {
$outfile = "$([System.IO.Path]::GetFileNameWithoutExtension($_.FullName)).coveragexml"
$output = [System.IO.Path]::Combine([System.IO.Path]::GetDirectoryName($_.FullName), $outfile)
"Analyse '$($_.Name)' with output '$outfile'..."
.$env:USERPROFILE\.nuget\packages\microsoft.codecoverage\15.8.0\build\netstandard1.0\CodeCoverage\CodeCoverage.exe analyze /output:$output $_.FullName
}
To make it work, make sure you have 'Inline PowerShell' task installed for the Marketplace and place it before 'Run Code Analysis' step in your build pipeline.
For those who use a self-hosted agent, you can also install Visual Studio Test Agent 2019.
It contains a CodeCoverage.exe file that the SonarQubeAnalyze#4 Azure DevOps task will find. SonarQube will be able to convert .coverage file into .coveragexml, according to this SonarQube documentation webpage.
Visual Studio Test Agent seems to be free. No need to pay for Visual Studio Enterprise.
I am just setting up a basic build with a very bare bones WebApi App, and I am getting a failed build, but without any errors or warnings... how can i figure out what is going wrong?
Project "d:\a\1\s\My.Project.Api.sln" (1) is building "d:\a\1\s\My.Project.Api\My.Project.Api.csproj" (2) on node 1 (default targets).
_CleanRecordFileWrites:
Creating directory "obj\Release\".
Done Building Project "d:\a\1\s\My.Project.Api\My.Project.Api.csproj" (default targets) -- FAILED.
Done Building Project "d:\a\1\s\My.Project.Api.sln" (default targets) -- FAILED.
Build FAILED.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.15
##[error]Process 'msbuild.exe' exited with code '1'.
Even any way I can get a useful log or error message would be great!
Edit:
I added /v:diag for the build arguments for verbose logging, but it really isn't seeming to help.
Before Visual Studio build task, you should use nuget restore to download packages your project is referring.
So please add a Nuget task before Visual Studio build task. Detail setting for NuGet task as below:
Command: restore
Path to solution, packages.config, or project.json: **/*.sln or select relative path for My.Project.Api.sln
Feeds to use: Feeds in my NuGet.config
In your build definition, there is a variable called system.debug which is set to false. Change this to true at the template or at the time of triggering and you will get the debug lines written by the build tasks. Inspect the debug lines and you might find the issue.
I'm trying to use SonarQube Scanner for MSBuild on a Xamarin project on macOS using mono. As MSBuild 15.0 is now shipped with Xamarin, I figured this could actually work.
I can successfully run the scanner's "begin" using mono like so:
mono sonar-scanner-msbuild-2/SonarQube.Scanner.MSBuild.exe begin /k:"KEY"
The command creates the following files:
.sonarqube/conf/SonarQubeAnalysisConfig.xml
.sonarqube/conf/SonarQubeRoslyn-cs.ruleset
.sonarqube/conf/cs/SonarLint.xml
Before running MSBuild, I've added the following import to the csproj files of my solution:
<Import Project="/Users/someuser/.local/share/Microsoft/MSBuild/14.0/Microsoft.Common.targets/ImportBefore/SonarQube.Integration.ImportBefore.targets" />
I'm running MSBuild using:
msbuild /t:Rebuild
Now the build starts correctly but eventually terminates with two errors:
"/Users/someuser/Project/Project.sln" (Rebuild target) (1) ->
"/Users/someuser/Project/Project.UI.iOS/Project.UI.iOS.csproj" (Rebuild target) (2) ->
"/Users/someuser/Project/Project.Core/Project.Core.csproj" (default target) (3:3) ->
(CoreCompile target) ->
CSC : error CS2001: Source file `/additionalfile:/Users/someuser/Project/.sonarqube/conf/cs/SonarLint.xml' could not be found [/Users/someuser/Project/Project.Core/Project.Core.csproj]
CSC : error CS2001: Source file `/additionalfile:/Users/someuser/Project/.sonarqube/conf/Project.Core_AnyCPU_Debug_1267/ProjectOutFolderPath.txt' could not be found [/Users/someuser/Project/Project.Core/Project.Core.csproj]
Both files do exist in the filesystem, the first file was created in the scanner's begin invocation and the second file was created during the MSBuild execution.
Why would MSBuild not be able to find / access these two files? Is there anything that can be done about it?
After checking with the folks taking care of MSBuild, the solution has been provided in this Github issue thread:
To quote radical's comment from the Github issue:
You could try building with csc by passing /p:CscToolExe=csc.exe /p:CscToolPath=/Library/Frameworks/Mono.framework/Versions/4.8.0/lib/mono/msbuild/15.0/bin/Roslyn/ to msbuild
Unfortunately, even though MSBuild works with the above adjustments, SonarQube fails afterwards. I will follow up with the SonarQube people to see whether this can be worked around.
I have configured SonarQube to work with my TFS 2013. I followed the steps as mentioned in the setup doc. When i try to give a build from TFS online or Visual Studio, I am able to successfully complete the steps before Finish the analysis and upload the results to SonarQube.
I get the error No ProjectInfo.xml files were found. Check that the analysis targets are referenced by the MSBuild projects being built.
I am unable to figure out what might me causing the issue. I checked one of the links : No ProjectInfo.xml files were found error from command prompt using MSBuild SonarQube Runner v1.0 which speaks about the command prompt. Can someone point out where the issue is?
Below is the error log:
2015-09-12T11:44:10.9194896Z Output directory: C:\a\6fb08ad4\.sonarqube\out
2015-09-12T11:44:10.9194896Z Config file: C:\a\6fb08ad4\.sonarqube\out
2015-09-12T11:44:10.9204886Z 11:44:10 AM Loading the SonarQube analysis config from C:\a\6fb08ad4\.sonarqube\conf\SonarQubeAnalysisConfig.xml
2015-09-12T11:44:10.9204886Z 11:44:10 AM Attempting to locate the CodeCoverage.exe tool...
2015-09-12T11:44:11.3231261Z 11:44:11 AM Multiple versions of VS are installed: 11, 12, 14
2015-09-12T11:44:11.3240831Z 11:44:11 AM Code coverage command line tool: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
2015-09-12T11:44:11.3240831Z 11:44:11 AM Fetching code coverage report information from TFS...
2015-09-12T11:44:11.3250829Z 11:44:11 AM Attempting to locate a test results (.trx) file...
2015-09-12T11:44:11.3250829Z 11:44:11 AM No test results files found
2015-09-12T11:44:11.3260828Z 11:44:11 AM Generating SonarQube project properties file to C:\a\6fb08ad4\.sonarqube\out\sonar-project.properties
2015-09-12T11:44:11.3270789Z ##[error]11:44:11 AM No ProjectInfo.xml files were found. Check that the analysis targets are referenced by the MSBuild projects being built.
2015-09-12T11:44:11.3270789Z 11:44:11 AM Writing processing summary to C:\a\6fb08ad4\.sonarqube\out\ProjectInfo.log
2015-09-12T11:44:11.3270789Z 11:44:11 AM Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.
2015-09-12T11:44:11.3280797Z 11:44:11 AM Creating a summary markdown file...
2015-09-12T11:44:11.3280797Z Process returned exit code 1
2015-09-12T11:44:11.3290776Z ##[error]Post-processing failed. Exit code: 1
2015-09-12T11:44:11.5740896Z ##[error]Unexpected exit code received from batch file: 1
2015-09-12T11:44:11.5790878Z ##[debug]summaryMdPath = C:\a\6fb08ad4\.sonarqube\out\summary.md
2015-09-12T11:44:11.5820880Z ##[debug]Uploading the summary.md file
Thanks!