I've a Visual Studio Team Services build definition containing a Visual Studio Build task surrounded by the Sonar Begin Analysis and End Analysis task. The Visual Studio Build packages a SharePoint provider hosted add-in using the /p:IsPackaging=True property. If this property is set I get the following error from the Sonar Build Runner:
2015-11-27T13:23:05.9534586Z WARNING: Duplicate project GUID: "31ef7995-fdbc-4307-9024-a3d640fdf987".
Check that the project is only being built for a single platform/configuration and that that
the project guid is unique. The project will not be analyzed by SonarQube.
Of course I could first build the solution without the /p:IsPackaging=True and running analysis on this and in a second step do the packaging, but this seems like a waste of resources to have to build the solutions twice.
Any idea how I can package a SharePoint provider hosted Add-In and use the same task for code analysis with Sonar?
Sonar version in use is 5.1.2. And MSBuild.SonarQube.Runner version used by the VSTS task is 1.0.1.
Apologies for answering with such a long delay!
I've had a look at this and it seems that the SharePoint msbuild targets are calling the "Build" target twice - once part of the normal build and once part of the packaging process. In order for SonarQube analysis to track all the build artefacts, we've injected some logic that depends on the Build task and now this logic is being called twice and you get the "Duplicate project GUID" problem.
Here's a workaround I tried on a simple SharePoint project - keep the actual build and the packaging as separate steps. So your build definition will be:
Note that the second call to msbuild needs to be done on your sharepoint project - calling /t:Package on the solution will not work because the SharePoint targets will have not been imported.
Please let me know if this works!