VSTS extension - Analyze task fails when building with x64 version of MSBuild

342 views
Skip to first unread message

galad...@gmail.com

unread,
Feb 28, 2018, 3:32:57 AM2/28/18
to SonarQube
Hello,

We have a build where we use the x64 version of MSBuild, and where the Analyze task fails with the following message:

2018-02-28T08:02:39.7032819Z The SonarQube MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
2018-02-28T08:02:39.7033200Z Possible causes:
2018-02-28T08:02:39.7033498Z 1. The project has not been built - the project must be built in between the begin and end steps
2018-02-28T08:02:39.7033884Z 2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0 upwards are supported
2018-02-28T08:02:39.7034280Z 3. The begin, build or end steps have not all been launched from the same folder

I was able to reproduce the issue on simple empty. The task succeed when using the x86 version, while it fails when using x64.

The MSBuild can be defined in the "Visual Studio Build"  task as following ("msbuildArchitecture" option in YAML build definitions).


I did not find any limitation about that in the documentation so I assume it is a bug.


Thanks,

Lucas Loegel


thi...@gmail.com

unread,
Feb 28, 2018, 7:15:10 PM2/28/18
to SonarQube
try sonar.visualstudio.skipIfNotBuilt=true in the Additional Properties box  

galad...@gmail.com

unread,
Mar 1, 2018, 2:40:40 AM3/1/18
to SonarQube
Hello,

Thanks for the answer. Unfortunately it has no effect, the task still fails.

I also saw that actually, the analyzers are not run when building the solution, while with MSBuild x86 they are (I see warnings of Sonarqube rules in the logs).
So I think that is the real issue here.

Amaury Leve

unread,
Mar 1, 2018, 3:25:32 AM3/1/18
to galad...@gmail.com, SonarQube
Hi,

Would you mind:
1. Sharing the versions of SonarQube instance you are analyzing against and the version of the VSTS extension
2. Sharing the log of the end-step with the /d:sonar.verbose=true or sonar.verbose=true (depends on the task version) flag as additional parameter.
3. Could you make a test with the standalone version of the scanner for msbuild? To see if you have the same behavior.

Cheers,
Amaury

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/b6a139f5-cc86-4eab-8cc5-3efc6b77ab6a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--

Amaury Levé | SonarSource

Software Developer - .Net Team

http://sonarsource.com


Are you using SonarLint in your IDE? 

galad...@gmail.com

unread,
Mar 6, 2018, 5:44:06 AM3/6/18
to SonarQube
Hello,

Here are the answers:
1. 

SonarQube version: 5.6.4

VSTS extension version: 4.0.0


2. Here the log provided by VSTS. 
2018-03-01T07:31:52.6572660Z ##[section]Starting: SonarQubeAnalyze
2018-03-01T07:31:52.6576546Z ==============================================================================
2018-03-01T07:31:52.6576881Z Task         : Run Code Analysis
2018-03-01T07:31:52.6577175Z Description  : Run scanner and upload the results to the SonarQube server.
2018-03-01T07:31:52.6577445Z Version      : 4.0.0
2018-03-01T07:31:52.6577687Z Author       : sonarsource
2018-03-01T07:31:52.6578068Z Help         : This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.

2018-03-01T07:31:52.6578506Z ==============================================================================
2018-03-01T07:31:54.0128625Z [command]C:\a\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.0.0\sonar-scanner-msbuild\SonarQube.Scanner.MSBuild.exe end
2018-03-01T07:31:54.0920816Z SonarQube Scanner for MSBuild 4.0.2
2018-03-01T07:31:54.1331142Z Default properties file was found at C:\a\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.0.0\sonar-scanner-msbuild\SonarQube.Analysis.xml
2018-03-01T07:31:54.1332222Z Loading analysis properties from C:\a\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.0.0\sonar-scanner-msbuild\SonarQube.Analysis.xml
2018-03-01T07:31:54.1332580Z Post-processing started.
2018-03-01T07:31:54.2518154Z 08:31:54.239  08:31:54.239  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.
2018-03-01T07:31:54.2599046Z The SonarQube MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
2018-03-01T07:31:54.2599651Z Possible causes:
2018-03-01T07:31:54.2599996Z   1. The project has not been built - the project must be built in between the begin and end steps
2018-03-01T07:31:54.2600387Z   2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0 upwards are supported
2018-03-01T07:31:54.2600824Z   3. The begin, build or end steps have not all been launched from the same folder
2018-03-01T07:31:54.2651028Z Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.
2018-03-01T07:31:54.2687995Z 08:31:54.254  Creating a summary markdown file...
2018-03-01T07:31:54.2696903Z 08:31:54.254  Post-processing failed. Exit code: 1
2018-03-01T07:31:54.2838518Z ##[error]C:\a\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.0.0\sonar-scanner-msbuild\SonarQube.Scanner.MSBuild.exe failed with return code: 1
2018-03-01T07:31:54.2849917Z ##[section]Finishing: SonarQubeAnalyze

In addition here are the command lines run by the Visual Studio Build task:
2018-03-01T07:31:45.6008854Z ##[command]"C:\a\_work\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.126.0\ps_modules\MSBuildHelpers\vswhere.exe" -version [15.0,16.0) -latest -format json
2018-03-01T07:31:46.0586991Z ##[command]"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\amd64\msbuild.exe" "C:\a\_work\41\s\Kitchen.targets" /nologo /nr:false /dl:CentralLogger,"C:\a\_work\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.126.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=02298353-5da9-40d4-9f22-92e89d4d0ce3|SolutionDir=C:\a\_work\41\s"*ForwardingLogger,"C:\a\_work\_tasks\VSBuild_71a9a2d3-a98a-4caa-96ab-affca411ecda\1.126.0\ps_modules\MSBuildHelpers\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"  /p:platform="any cpu" /p:configuration="release" /p:VisualStudioVersion="15.0" /m /p:_MSDeployUserAgent="VSTS_0068808c-dad4-4a55-b837-4eaba3ff3f98_build_186_53828"

3. I was unable to reproduce the issue using the standalone version (4.0.1) on my computer. I will try test it directly on the build machine in order to have the same conditions.

I think the error occurs because the analyzers are not run, because when it works with the x86 version I can see a  few warning of SonarQube rules.

Thanks for your help.

Amaury Leve

unread,
Mar 9, 2018, 3:48:38 AM3/9/18
to galad...@gmail.com, SonarQube
Hi,

For point 2, the log doesn't seem to be the debug log. Could you run the analysis with sonar.verbose=true in the additional parameters of the begin task?

Point 3, have you managed to test on the server directly with the scanner?

I'll try to make a few more tests next week to reproduce the issue. Best thing would be for you to provide us some small reproducer (small project and commands to use).

Cheers,
Amaury


For more options, visit https://groups.google.com/d/optout.
Message has been deleted

galad...@gmail.com

unread,
Mar 12, 2018, 1:45:46 PM3/12/18
to SonarQube
Hi,

Indeed, I didn't enable the debug log.
I put all the logs for the begin task, the Visual Studio build task and the end task here: https://drive.google.com/open?id=1f7Bwn6C6X73s2Xq_H87xAH9ZQ6YFrKGL
I also added the logs of those tasks when the analyze task succeed using MSBuild x86.
I also added the small projet that I used for the tests (TestSonar.zip). Inside there is the file .vsts-ci.yml which contains the build definition.

I was able to test the scanner directly on the server and it succeeded to run the analyzers and publish the result to the SonarQube server. I even ran the scanner in the folder that the VSTS agent cloned the repository for its build task (C:\a\_work\7).

This is really strange to not being able to reproduce the issue since the conditions are almost the same.

One thing that might differ is that the VSTS agent is run with the local system account (NT AUTHORITY\SYSTEM). I will try to test with this account as well.

Thanks,
Lucas Loegel

Amaury Leve

unread,
Mar 13, 2018, 4:58:16 AM3/13/18
to galad...@gmail.com, SonarQube
Hi,

The user account is actually a key thing here. Sorry not to have asked before...
If you look at this ticket you'll see that we don't have the right behavior when run under a system account: https://jira.sonarsource.com/browse/SONARMSBRU-374
We haven't been able to fix correctly the issue yet so for now we have added a special log and we recommend users to run through a non-system account.

Please ping me if you still have the issue after this user change.

Cheers,
Amaury


For more options, visit https://groups.google.com/d/optout.

galad...@gmail.com

unread,
Mar 13, 2018, 10:26:14 AM3/13/18
to SonarQube
Wow, thanks, that makes so much sense now.
I'm not sure if there is a reason why we the local system account, I'll need to check why and if we can change that.

Thanks a lot Amaury,
Lucas Loegel
Reply all
Reply to author
Forward
0 new messages