gpt4 book ai didi

msbuild - 代码覆盖率结果的 MSBuild.SonarQube.Runner.exe 结束命令出错

转载 作者:行者123 更新时间:2023-12-02 16:45:33 29 4
gpt4 key购买 nike

我正在尝试运行 C# 代码覆盖率结果导入,但在最后一步出现错误。我通过 Visual Studio 创建了 .coveragexml 文件(名为 test.coveragexml)(测试 - 分析代码覆盖率 - 所有测试),并将其保存在项目目录中。在 CMD 中运行以下命令:

  1. C:\SonarQube\bin\MSBuild.SonarQube.Runner.exe 开始/k:MyProject/n: MyProject/v:1.0/d:sonar.cs.vscoveragexml.reportsPaths=D:\sTFS\24115\Sources\MyProject\Source*.coveragexml/d:sonar.verbose=true
  2. 构建(通过 Visual Studio)
  3. C:\SonarQube\bin\MSBuild.SonarQube.Runner.exe 结束

对于最后一步,我收到此错误:

10:09:29 AM  ERROR: Error during Sonar runner execution
10:09:29 AM ERROR: Unable to execute Sonar
10:09:29 AM ERROR: Caused by: Error while parsing the XML file: D:\sTFS\24115\S
ources\SystemMapping\Source\test.coveragexml
10:09:29 AM ERROR: Caused by: Unexpected character '?' (code 65533 / 0xfffd) in
prolog; expected '<'
10:09:29 AM at [row,col {unknown-source}]: [1,1]
10:09:29 AM ERROR:
10:09:29 AM ERROR: To see the full stack trace of the errors, re-run SonarQube
Runner with the -e switch.
10:09:29 AM ERROR: Re-run SonarQube Runner using the -X switch to enable full d
ebug logging.
10:09:29 AM The sonar-runner did not complete successfully
Post-processing failed. Exit code: 1

找不到任何字符“?”在文件...来自日志:

M  10:09:29.021 INFO  - Sensor org.sonar.plugins.csharp.CSharpSensor@5945ac done: 12370 ms
10:09:29 AM 10:09:29.021 INFO - Sensor org.sonar.plugins.csharp.CSharpCodeCoverageProvider$CSharpCoverageReportImportSensor@ed32df...
10:09:29 AM 10:09:29.104 INFO - Parsing the Visual Studio coverage XML report D:\sTFS\24115\Sources\SystemMapping\Source\test.coveragexml
10:09:29 AM 10:09:29.110 DEBUG - Release semaphore on project : org.sonar.api.resources.Project@101ba81[id=37975,key=SystemMapping,qualifier=TRK], with key batch-SystemMapping
10:09:29 AM INFO: ------------------------------------------------------------------------
10:09:29 AM INFO: EXECUTION FAILURE
10:09:29 AM INFO: ------------------------------------------------------------------------
10:09:29 AM Total time: 21.544s
10:09:29 AM Final Memory: 13M/121M
10:09:29 AM INFO: ------------------------------------------------------------------------
10:09:29 AM Process returned exit code 1
10:09:29 AM Creating a summary markdown file...
Process returned exit code 1

最佳答案

我终于成功创建了代码覆盖率分析!

  1. 将 MSBuild.SonarQube.Runner 移至与我的项目相同的根目录
  2. 切换到 OpenCover 覆盖范围 xml 并按照此处指定的命令工作 -
  3. 从 Visual Studio 命令提示符运行命令

这是我执行的命令(带有 2 个单元测试 dll):D:\SonarQube\bin\MSBuild.SonarQube.Runner.exe 开始/k:MyProject/n: MyProject/v:1.0/d:sonar.cs.opencover.reportsPaths="D:\SonarQube\6.5\NP\MyProject\源\opencover*.xml"/d:sonar.verbose=true

构建我的项目

“C:\OpenCover\OpenCover.Console.exe”-输出:“D:\SonarQube\6.5\NP\MyProject\Source\opencover1.xml”-register:用户-目标:“C:\Program Files( x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe"-targetargs:"D:\SonarQube\6.5\NP\MyProject\Source\MyProject.Test\bin\Debug\MyProject .Test.dll”

“C:\OpenCover\OpenCover.Console.exe”-输出:“D:\SonarQube\6.5\NP\MyProject\Source\opencover2.xml”-register:用户-目标:“C:\Program Files( x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe"-targetargs:"D:\SonarQube\6.5\NP\MyProject\Source\MyProject.test\bin\Debug\MyProject .test.dll”

D:\SonarQube\bin\MSBuild.SonarQube.Runner.exe 结束 > log.txt

希望对其他人有帮助:)

关于msbuild - 代码覆盖率结果的 MSBuild.SonarQube.Runner.exe 结束命令出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34402358/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com