【问题标题】:Can SonarQube Scanner for MSBuild be run from within a powershell script?可以从 powershell 脚本中运行用于 MSBuild 的 SonarQube Scanner 吗?
【发布时间】:2016-06-07 06:30:13
【问题描述】:

我无法让 MSBuild Sonar Runner 在 powershell 脚本中工作。示例脚本如下所示,遵循从同一目录执行所有步骤的文档化过程。

$sonarRunnerPath = "C:\Users\glenn\MSBuild.SonarQube.Runner-2.0\MSBuild.SonarQube.Runner.exe"
$msbuildPath = "$env:WINDIR\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe"

Push-Location $slnDir
& $sonarRunnerPath begin /k:proj:alpha "/n:Project Alpha" /v:1.0.0.%BUILD_NUMBER% /d:sonar.host.url=http://sonar.local
& $msbuildPath /nologo /t:Build /nologo /v:n /clp:ErrorsOnly /m /p:Configuration=Release
& $sonarRunnerPath end

但是在构建(第二步)之后我注意到 $slnDir/.sonarqube/out 目录是空的,然后在运行结束命令后我收到标准错误消息:

No ProjectInfo.xml files were found. Possible causes:

关于为什么在 powershell 中运行 msbuild 会阻止 msbuild 生成 ProjectInfo.xml 输出文件的任何想法?

【问题讨论】:

  • %BUILD_NUMBER% 是环境变量吗?你应该使用$env:BUILD_NUMBER。如果可以的话,您应该考虑使用相对应的完整路径。

标签: powershell msbuild sonarqube


【解决方案1】:

SonarQube Scanner for MSBuild 最适合 MSBuild 版本 14。不支持 MSBuild 4,这就是您看到此 No ProjectInfo.xml files were found. Possible causes: 错误的原因。请注意,Possible causes 下的几行中提到了这一点;-)

更多详情请参考官方文档:http://docs.sonarqube.org/x/ahFq

【讨论】:

  • 哇,坐在那儿盯着我看,我显然不熟悉 MSBuild 的标准工具路径。我在我的路径中安装了 MSBuild 14,所以我忽略了错误消息的那部分,因为它在命令行上工作。这还增加了在运行所有 3 个命令时不需要位于解决方案目录中的额外改进。谢谢!
猜你喜欢
  • 2018-09-02
  • 2019-02-25
  • 1970-01-01
  • 2020-05-06
  • 1970-01-01
  • 2017-10-14
  • 2018-08-12
  • 2017-02-20
  • 2017-03-24
相关资源
最近更新 更多