Using Sonar MSBuild Runner with /p:IsPackaging=True

痴心易碎 提交于 2020-01-04 03:51:12

问题


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.


回答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:

  • SonarQube Begin
  • MSBuild (without /p:IsPackaging=true)
  • SonarQube End
  • MSBuild your_SP_project.csproj /t:Package

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!



来源:https://stackoverflow.com/questions/33996594/using-sonar-msbuild-runner-with-pispackaging-true

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!