Tfs 警告:使用SonarQube时未找到Protobuf文件

Tfs 警告:使用SonarQube时未找到Protobuf文件,tfs,msbuild,sonarqube,sonarqube-scan,Tfs,Msbuild,Sonarqube,Sonarqube Scan,我刚刚开始使用SonarQube,它确实运行了这么久。 IT部门已经为我们的Team Foundation Server设置了SonarQube 6.2,并且我已经在我的Bu建dAgent上安装和配置了MSBug扫描器。 我在生成定义的XAML模板中调用了msbuild scanner,它确实运行了,但它给了我一个警告,这使我的生成“部分成功”。 这是错误消息: 07:53:01.658警告:找不到Protobuf文件: d:\b\210\474.sonarqube\out\ReferenceM

我刚刚开始使用SonarQube,它确实运行了这么久。 IT部门已经为我们的Team Foundation Server设置了SonarQube 6.2,并且我已经在我的Bu建dAgent上安装和配置了MSBug扫描器。 我在生成定义的XAML模板中调用了msbuild scanner,它确实运行了,但它给了我一个警告,这使我的生成“部分成功”。 这是错误消息:

07:53:01.658警告:找不到Protobuf文件: d:\b\210\474.sonarqube\out\ReferenceManager\U x86\U Release\U 6561\output cs\issues.pb

issues.pb文件确实丢失了,但为什么我会因此收到错误/警告?当我从命令行运行scanner和msbuild时,我没有得到这一点,只有在team build中运行in时。但在命令行上运行时,也没有issues.pb文件

从命令行运行扫描仪时,我得到以下输出:

09:34:05.959 INFO: 97 files indexed
09:34:05.985 INFO: Quality profile for cs: Sonar way
09:34:05.992 DEBUG: Code colorizer, supported languages: 
09:34:07.008 DEBUG: 'Generic Coverage Report' skipped because one of the required properties is missing
09:34:07.009 DEBUG: 'Generic Test Executions Report' skipped because one of the required properties is missing
09:34:07.018 DEBUG: 'SurefireSensor' skipped because there is no related file in current project
09:34:07.023 DEBUG: 'JaCoCoSensor' skipped because there is no related file in current project
09:34:07.025 DEBUG: 'JavaSquidSensor' skipped because there is no related file in current project
09:34:07.025 DEBUG: 'JavaScript Squid Sensor' skipped because there is no related file in current project
09:34:07.027 DEBUG: Sensors : Lines Sensor -> SCM Sensor -> C# -> Coverage Report Import -> Coverage Report Import -> Unit Test Results Import -> XmlFileSensor -> Zero Coverage Sensor -> Code Colorizer Sensor -> CPD Block Indexer
09:34:07.029 INFO: Sensor Lines Sensor
09:34:07.279 INFO: Sensor Lines Sensor (done) | time=250ms
09:34:07.279 INFO: Sensor SCM Sensor
09:34:07.279 INFO: SCM Publisher is disabled
09:34:07.281 INFO: Sensor SCM Sensor (done) | time=2ms
09:34:07.281 INFO: Sensor C#
09:34:07.292 INFO: SonarAnalyzer.Scanner needs to be executed: false
09:34:07.292 INFO: Importing analysis results from C:\Users\Build-SW-Dev\Desktop\.sonarqube\out\ReferenceManager_x86_Release_5730\output-cs
09:34:08.749 INFO: Importing Roslyn report
09:34:08.998 INFO: Sensor C# (done) | time=1717ms
11:12:51.390 INFO: 97 files indexed
11:12:51.422 INFO: Quality profile for cs: Sonar way
11:12:51.422 DEBUG: Code colorizer, supported languages: 
11:12:52.468 DEBUG: 'Generic Coverage Report' skipped because one of the required properties is missing
11:12:52.468 DEBUG: 'Generic Test Executions Report' skipped because one of the required properties is missing
11:12:52.468 DEBUG: 'SurefireSensor' skipped because there is no related file in current project
11:12:52.468 DEBUG: 'JaCoCoSensor' skipped because there is no related file in current project
11:12:52.468 DEBUG: 'JavaSquidSensor' skipped because there is no related file in current project
11:12:52.468 DEBUG: 'JavaScript Squid Sensor' skipped because there is no related file in current project
11:12:52.484 DEBUG: Sensors : Lines Sensor -> SCM Sensor -> C# -> Coverage Report Import -> Coverage Report Import -> Unit Test Results Import -> XmlFileSensor -> Zero Coverage Sensor -> Code Colorizer Sensor -> CPD Block Indexer
11:12:52.484 INFO: Sensor Lines Sensor
11:12:52.562 INFO: Sensor Lines Sensor (done) | time=78ms
11:12:52.562 INFO: Sensor SCM Sensor
11:12:52.562 INFO: SCM Publisher is disabled
11:12:52.562 INFO: Sensor SCM Sensor (done) | time=0ms
11:12:52.562 INFO: Sensor C#
11:12:52.562 INFO: SonarAnalyzer.Scanner needs to be executed: false
11:12:52.562 INFO: Importing analysis results from d:\b\210\474\.sonarqube\out\ReferenceManager_x86_Release_1481\output-cs
11:12:53.078 WARN: Protobuf file not found: d:\b\210\474\.sonarqube\out\ReferenceManager_x86_Release_1481\output-cs\issues.pb
11:12:53.718 INFO: Sensor C# (done) | time=1156ms
在团队构建期间运行扫描仪时,我得到以下输出:

09:34:05.959 INFO: 97 files indexed
09:34:05.985 INFO: Quality profile for cs: Sonar way
09:34:05.992 DEBUG: Code colorizer, supported languages: 
09:34:07.008 DEBUG: 'Generic Coverage Report' skipped because one of the required properties is missing
09:34:07.009 DEBUG: 'Generic Test Executions Report' skipped because one of the required properties is missing
09:34:07.018 DEBUG: 'SurefireSensor' skipped because there is no related file in current project
09:34:07.023 DEBUG: 'JaCoCoSensor' skipped because there is no related file in current project
09:34:07.025 DEBUG: 'JavaSquidSensor' skipped because there is no related file in current project
09:34:07.025 DEBUG: 'JavaScript Squid Sensor' skipped because there is no related file in current project
09:34:07.027 DEBUG: Sensors : Lines Sensor -> SCM Sensor -> C# -> Coverage Report Import -> Coverage Report Import -> Unit Test Results Import -> XmlFileSensor -> Zero Coverage Sensor -> Code Colorizer Sensor -> CPD Block Indexer
09:34:07.029 INFO: Sensor Lines Sensor
09:34:07.279 INFO: Sensor Lines Sensor (done) | time=250ms
09:34:07.279 INFO: Sensor SCM Sensor
09:34:07.279 INFO: SCM Publisher is disabled
09:34:07.281 INFO: Sensor SCM Sensor (done) | time=2ms
09:34:07.281 INFO: Sensor C#
09:34:07.292 INFO: SonarAnalyzer.Scanner needs to be executed: false
09:34:07.292 INFO: Importing analysis results from C:\Users\Build-SW-Dev\Desktop\.sonarqube\out\ReferenceManager_x86_Release_5730\output-cs
09:34:08.749 INFO: Importing Roslyn report
09:34:08.998 INFO: Sensor C# (done) | time=1717ms
11:12:51.390 INFO: 97 files indexed
11:12:51.422 INFO: Quality profile for cs: Sonar way
11:12:51.422 DEBUG: Code colorizer, supported languages: 
11:12:52.468 DEBUG: 'Generic Coverage Report' skipped because one of the required properties is missing
11:12:52.468 DEBUG: 'Generic Test Executions Report' skipped because one of the required properties is missing
11:12:52.468 DEBUG: 'SurefireSensor' skipped because there is no related file in current project
11:12:52.468 DEBUG: 'JaCoCoSensor' skipped because there is no related file in current project
11:12:52.468 DEBUG: 'JavaSquidSensor' skipped because there is no related file in current project
11:12:52.468 DEBUG: 'JavaScript Squid Sensor' skipped because there is no related file in current project
11:12:52.484 DEBUG: Sensors : Lines Sensor -> SCM Sensor -> C# -> Coverage Report Import -> Coverage Report Import -> Unit Test Results Import -> XmlFileSensor -> Zero Coverage Sensor -> Code Colorizer Sensor -> CPD Block Indexer
11:12:52.484 INFO: Sensor Lines Sensor
11:12:52.562 INFO: Sensor Lines Sensor (done) | time=78ms
11:12:52.562 INFO: Sensor SCM Sensor
11:12:52.562 INFO: SCM Publisher is disabled
11:12:52.562 INFO: Sensor SCM Sensor (done) | time=0ms
11:12:52.562 INFO: Sensor C#
11:12:52.562 INFO: SonarAnalyzer.Scanner needs to be executed: false
11:12:52.562 INFO: Importing analysis results from d:\b\210\474\.sonarqube\out\ReferenceManager_x86_Release_1481\output-cs
11:12:53.078 WARN: Protobuf file not found: d:\b\210\474\.sonarqube\out\ReferenceManager_x86_Release_1481\output-cs\issues.pb
11:12:53.718 INFO: Sensor C# (done) | time=1156ms

使用google找不到有关此错误的任何信息。感谢您的帮助

通过查看CSharpSencor.java中的代码,我认为命令行构建和团队构建之间的差异是由RoslynReportPath造成的:

void executeInternal(SensorContext context) {
  boolean requiresAnalyzerScannerExecution = !config.isReportsComingFromMSBuild();

  LOG.info("SonarAnalyzer.Scanner needs to be executed: " + requiresAnalyzerScannerExecution);

  String roslynReportPath = settings.getString(config.getRoslynJsonReportPathProperty());
  boolean hasRoslynReportPath = roslynReportPath != null;

  Path protobufReportsDirectory;
  if (requiresAnalyzerScannerExecution) {
    // MSBuild 12 or MSBuild 14 with old scanner
    analyze(!hasRoslynReportPath, context);
    protobufReportsDirectory = protobufReportPathForMSBuild12(context);
  } else {
    protobufReportsDirectory = config.protobufReportPathFromScanner();
  }

  LOG.info("Importing analysis results from " + protobufReportsDirectory.toAbsolutePath().toString());
  importResults(context, protobufReportsDirectory, !hasRoslynReportPath);

  if (hasRoslynReportPath) {
    LOG.info("Importing Roslyn report");
    importRoslynReport(roslynReportPath, context);
  }
}
命令行生成:

...
Generating SonarQube project properties file to C:\Users\Build-SW-Dev\Desktop\.sonarqube\out\sonar-project.properties
The supplied Code Analysis ErrorLog file is a valid json file and does not need to be fixed: d:\b\210\474\src\TPA\DevTools_Source\internal\ReferenceManager\main\ReferenceManager\bin\Release\ReferenceManager.exe.RoslynCA.json
...
08:41:57.276 INFO: Sensor C#
08:41:57.291 INFO: SonarAnalyzer.Scanner needs to be executed: false
08:41:57.291 INFO: Importing analysis results from C:\Users\Build-SW-Dev\Desktop\.sonarqube\out\ReferenceManager_x86_Release_6194\output-cs
08:41:59.948 INFO: Importing Roslyn report
08:42:00.448 INFO: Sensor C# (done) | time=3172ms
团队建设:

...
Generating SonarQube project properties file to d:\b\210\474\.sonarqube\out\sonar-project.properties
No Code Analysis ErrorLog file found at d:\b\210\474\bin\ReferenceManager.exe.RoslynCA.json.
...
11:12:52.562 INFO: Sensor C#
11:12:52.562 INFO: SonarAnalyzer.Scanner needs to be executed: false
11:12:52.562 INFO: Importing analysis results from d:\b\210\474\.sonarqube\out\ReferenceManager_x86_Release_1481\output-cs
11:12:53.078 WARN: Protobuf file not found: d:\b\210\474\.sonarqube\out\ReferenceManager_x86_Release_1481\output-cs\issues.pb
11:12:53.718 INFO: Sensor C# (done) | time=1156ms
虽然我还没有一个解决方案,但一个解决方法是将msbuild扫描程序的输出重定向到一个文件中。TFS则不会看到警告,也不会使生成部分成功

编辑: 现在我已经找到了根本原因:)在团队构建期间,所有输出文件都通过脚本移动到子文件夹中。这就是为什么SonarQube找不到文件“d:\b\210\474\bin\ReferenceManager.exe.RoslynCA.json”。
文件位于子文件夹中…

您使用的是哪个版本的TFS?通常,警告不会导致生成部分成功,您是否有特定设置?我们使用TFS 2015和xaml生成模板。我在XAML模板的测试部分的生成后部分中调用“MSBuild.SonarQube.Runner.exe end”,如前所述,她:TFS将此警告转换为错误:在测试运行程序之后运行可选脚本09:41:38.799警告:找不到Protobuf文件:d:\b\210\474\.sonarqube\out\ReferenceManager\U x86\U Release\U 4068\output cs\issues.pb当您查看登录到VS。。。