【问题标题】:TeamCity with SonarQube for Code Analysis build fails使用 SonarQube 进行代码分析构建的 TeamCity 失败
【发布时间】:2018-10-30 21:29:03
【问题描述】:

对于许多用户来说非常常见的问题,SonarQube 代码分析失败并出现错误:

[10:06:05]No ProjectInfo.xml files were found. Possible causes: 
[10:06:05]1. The project has not been built - the end step was called right 
after the begin step, without a build step in between 
[10:06:05]2. An unsupported version of MSBuild has been used to build the 
project. Currently MSBuild 12.0 upwards are supported
[10:06:05]3. The build step has been launched from a different working folder
[10:06:05]Post-processing failed. Exit code: 1
[10:06:05]Process exited with code 1

很多参考资料都说修复是使用 MSBuild.exe 的完整路径,但是是的,我使用完整路径,而且我使用最新 C# 版本的 MSBuild 15.0 版本,旧的 MSBuild 只是因为代码中的新 C# 功能而失败.

但是我无法摆脱这个错误,我不知道可以做些什么,所以也许你们中的任何人已经遇到过这个问题并且可以帮助我?

已编辑

我很确定这些步骤都不应该是失败的原因,第二个只是最接近的一个,因为我的构建步骤是

Team City 构建步骤如下所示。

第 XX 步:

cd %projectDirectory%
"C:\sonarqube-5.3\bin\MSBuild.SonarQube.Runner\MSBuild.SonarQube.Runner.exe" begin   ... params
"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\msbuild.exe" "MyProject.sln" /t:Clean;Rebuild

步骤 XY:

...

Step XZ:(最后一个)

cd %projectDirectory%
"C:\sonarqube-5.3\bin\MSBuild.SonarQube.Runner\MSBuild.SonarQube.Runner.exe" end

对我来说,它看起来非常简单易懂,但我仍然得到了那个错误,我不知道为什么,错误是在最后一步 (XZ) 中抛出的。

【问题讨论】:

  • 您的问题涉及潜在原因 #2。 #1 和 #3 呢?
  • 感谢您的回复,我编辑了一点我的问题,也许这会提供更多关于我的问题的细节
  • 第 XY 步会发生什么?该步骤/那些步骤是否会干扰“结束分析”步骤所需的数据/工件?如果省略步骤 XY,分析是否成功?
  • 还有其他 javascript,resharper 正在运行,实际上它在 c# 版本更新和新的 MSBuild 版本使用之前运行良好,所以我想知道 MSBuild 新版本是否不会生成 ProjectInfo.xml 或任何其他东西正在发生

标签: c# msbuild sonarqube teamcity analysis


【解决方案1】:

您需要升级到更新版本的 Scanner for MSBuild。我建议升级到最新的可用版本(在撰写本文时为 v4.2)。

扫描程序会在以下位置为每个受支持的 MBuild 版本复制一个目标文件:%localappdata%\Microsoft\MSBuild[MSBuild version]\Microsoft.Common.targets\ImportBefore。

从日志输出的外观来看,您使用的 Scanner for MSBuild 版本早于 MSBuild 15 的发布,因此不会将文件复制到特定于 MSBuild15 的位置。这将导致“未找到 ProjectInfo.xml 文件”状态。

如果扫描程序日志中的警告消息明确列出了支持的 MSBuild 版本范围,那就更好了。 “此版本的 Scanner 支持 MSBuild v12.0 到 v14.0”。我创建了issue #502 来跟踪它。

【讨论】:

    猜你喜欢
    • 2016-01-13
    • 2017-04-29
    • 1970-01-01
    • 2018-02-27
    • 1970-01-01
    • 1970-01-01
    • 2016-06-05
    • 2015-08-12
    • 2019-03-15
    相关资源
    最近更新 更多