将Sonar MSBuild Runner与/p:IsPackaging = True一起使用 [英] Using Sonar MSBuild Runner with /p:IsPackaging=True

查看:138
本文介绍了将Sonar MSBuild Runner与/p:IsPackaging = True一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Visual Studio Team Services构建定义,其中包含一个由Sonar Begin Analysis和End Analysis任务包围的Visual Studio Build任务. Visual Studio Build使用/p:IsPackaging = True属性将SharePoint提供程序承载的加载项打包.如果设置了此属性,我会从Sonar Build Runner获得以下错误:

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. 

当然,我可以先在没有/p:IsPackaging = True的情况下构建解决方案,然后对此进行运行分析,然后在第二步中进行打包,但这似乎浪费了资源,必须两次构建解决方案.

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.

有什么主意如何打包SharePoint提供程序托管的加载项,并使用同一任务通过Sonar进行代码分析?

Any idea how I can package a SharePoint provider hosted Add-In and use the same task for code analysis with Sonar?

使用的声纳版本为5.1.2. VSTS任务使用的MSBuild.SonarQube.Runner版本是1.0.1.

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!

我已经看过这个了,SharePoint msbuild目标似乎两次调用了"Build"目标-一次是正常构建的一部分,一次是打包过程的一部分.为了使SonarQube分析能够跟踪所有构建工件,我们注入了一些依赖于Build任务的逻辑,现在该逻辑被调用了两次,您遇到了重复项目GUID"问题.

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.

这是我在一个简单的SharePoint项目上尝试过的解决方法-将实际生成和打包保留为单独的步骤.因此,您的构建定义将为:

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开始
  • MSBuild(不带/p:IsPackaging = true)
  • SonarQube结束
  • MSBuild your_SP_project.csproj/t:Package

请注意,必须在您的共享点项目上完成对msbuild的第二次调用-在解决方案上调用/t:Package将不起作用,因为尚未导入SharePoint目标.

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!

这篇关于将Sonar MSBuild Runner与/p:IsPackaging = True一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆