Sonar和TFS 2013:未找到ProjectInfo.xml文件

Mli*_*Mli 1 msbuild tfs sonar-runner sonarqube

当我用声纳运行TFS 2013时,我收到以下错误: No ProjectInfo.xml files were found. Check that the analysis targets are referenced by the MSBuild projects being built.

信息: TF270015: 'SonarQube.MSBuild.Runner.exe' returned an unexpected exit code. Expected '0'; actual '1'.

我用 :

  • sonarqube-5.1.zip
  • 声纳CSHARP-插件-4.0.jar
  • SonarQube.MSBuild.Runner-0.9.zip
  • sonar-runner-dist-2.4.zip

我已按照"SonarQube现有TFS环境安装指南.pdf"中的说明进行操作.

有帮助吗?

谢谢.

记录:

SonarQube Analysis Summary
Analysis failed for SonarQube project "WpfApplication2", version 1.0
Product projects: 0, test projects: 0
Invalid projects: 0, skipped projects: 0, excluded projects: 0
Résumé
Debug | x86
0 erreur(s), 1 avertissement(s)
$/Essai2/WpfApplication2/WpfApplication2.sln - 0 erreur(s), 1 avertissement(s),
Afficher le fichier journal
C:\Builds\1\Essai2\WpfApplication2\src\documents\visual studio 2013\Projects\WpfApplication2\WpfApplication2.sln.metaproj : The specified solution configuration "Debug|x86" is invalid. Please specify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform="Any CPU") or leave those properties blank to use the default solution configuration.
$/Essai2/WpfApplication2/WpfApplication2.sln compilé
Aucun résultat des tests
Aucun résultat de couverture du code
Autres erreurs et avertissements
2 erreur(s), 0 avertissement(s)
01:45:52: No ProjectInfo.xml files were found. Check that the analysis targets are referenced by the MSBuild projects being built.
Exception Message: TF270015: 'SonarQube.MSBuild.Runner.exe' returned an unexpected exit code. Expected '0'; actual '1'. See the build logs for more details. (type UnexpectedExitCodeException)
Exception Stack Trace:    at System.Activities.Statements.Throw.Execute(CodeActivityContext context)
   at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
   at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

这是Diagnostic(我截断了源代码检查部分):


Compile, Test and Publish00:00:46


Run optional script before MSBuild00:00:08

InputsEnvironmentVariables: 
Enabled: True
Arguments: /key:WpfApplication2 /name:WpfApplication2 /version:1.0
FilePath: C:\sonarqube\bin\SonarQube.MSBuild.Runner.exe

OutputsResult: 0

C:\sonarqube\bin\SonarQube.MSBuild.Runner.exe /key:WpfApplication2 /name:WpfApplication2 /version:1.0

Pre-processing (3 arguments passed)

Using environment variables to determine the download directory...

Using environment variable 'TF_BUILD_BUILDDIRECTORY', value 'C:\Builds\1\Essai2\WpfApplication2'

Creating the analysis bin directory: C:\Builds\1\Essai2\WpfApplication2\sqtemp\bin

SonarQube server url: http://localhost:9000

Downloading SonarQube.MSBuild.Runner.Implementation.zip from http://localhost:9000/static/csharp/SonarQube.MSBuild.Runner.Implementation.zip to C:\Builds\1\Essai2\WpfApplication2\sqtemp\bin\SonarQube.MSBuild.Runner.Implementation.zip

Executing file C:\Builds\1\Essai2\WpfApplication2\sqtemp\bin\SonarQube.MSBuild.PreProcessor.exe

Args: "/key:WpfApplication2" "/name:WpfApplication2" "/version:1.0"

Working directory: C:\Builds\1\Essai2\WpfApplication2\sqtemp\bin

Timeout (ms):300000

Process id: 4168

01:45:11: The path to the sonar-runner.properties file was not supplied on the command line. Attempting to locate the file...

01:45:11: Located the runner properties file: C:\sonar-runner-2.4\conf\sonar-runner.properties

01:45:11: Legacy TeamBuild environment detected

01:45:11: Creating config and output folders...

01:45:11: Removing the existing directory: C:\Builds\1\Essai2\WpfApplication2\sqtemp\conf

01:45:11: Creating directory: C:\Builds\1\Essai2\WpfApplication2\sqtemp\conf

01:45:11: Removing the existing directory: C:\Builds\1\Essai2\WpfApplication2\sqtemp\out

01:45:11: Creating directory: C:\Builds\1\Essai2\WpfApplication2\sqtemp\out

Generating the FxCop ruleset...

01:45:14: Saving the config file to C:\Builds\1\Essai2\WpfApplication2\sqtemp\conf\SonarQubeAnalysisConfig.xml

Process returned exit code 0


Run MSBuild00:00:12

InputsProjectsToBuild: String[] Array
MSBuildMultiProc: True
Verbosity: Normal
ToolPlatform: Auto
Targets: 
RunCodeAnalysis: AsConfigured
CommandLineArguments: /p:SkipInvalidConfigurations=true /p:Configuration=Debug /p:Platform="Any CPU"
ConfigurationsToBuild: String[] Array
OutputLocation: SingleFolder
Enabled: True
ToolVersion: 
CleanBuild: True
OutDir: 
RestoreNuGetPackages: True

C:\Program Files\Microsoft Team Foundation Server 12.0\Tools\nuget.exe restore "C:\Builds\1\Essai2\WpfApplication2\src\documents\visual studio 2013\Projects\WpfApplication2\WpfApplication2.sln" -NonInteractive 

C:\Program Files (x86)\MSBuild\12.0\bin\amd64\MSBuild.exe /nologo /noconsolelogger "C:\Builds\1\Essai2\WpfApplication2\src\documents\visual studio 2013\Projects\WpfApplication2\WpfApplication2.sln" /nr:False /fl /flp:"logfile=C:\Builds\1\Essai2\WpfApplication2\src\documents\visual studio 2013\Projects\WpfApplication2\WpfApplication2.log;encoding=Unicode;verbosity=normal" /p:SkipInvalidConfigurations=true /p:Configuration=Debug /p:Platform="Any CPU" /m /p:OutDir="C:\Builds\1\Essai2\WpfApplication2\bin\\" /p:Configuration="Debug" /p:Platform="x86" /p:VCBuildOverride="C:\Builds\1\Essai2\WpfApplication2\src\documents\visual studio 2013\Projects\WpfApplication2\WpfApplication2.sln.x86.Debug.vsprops" /dl:WorkflowCentralLogger,"C:\Program Files\Microsoft Team Foundation Server 12.0\Tools\Microsoft.TeamFoundation.Build.Server.Logger.dll";"Verbosity=Normal;BuildUri=vstfs:///Build/Build/52;IgnoreDuplicateProjects=False;InformationNodeId=12;TargetsNotLogged=GetNativeManifest,GetCopyToOutputDirectoryItems,GetTargetPath;LogProjectNodes=True;LogWarnings=True;TFSUrl=http://localhost:8080/tfs/DefaultCollection;"*WorkflowForwardingLogger,"C:\Program Files\Microsoft Team Foundation Server 12.0\Tools\Microsoft.TeamFoundation.Build.Server.Logger.dll";"Verbosity=Normal;" /p:BuildId="dbda6e4d-d5bc-4eed-8b3e-6cc79e3721cc,vstfs:///Build/Build/52" /p:BuildLabel="WpfApplication2_20150615.3" /p:BuildTimestamp="Mon, 15 Jun 2015 11:44:59 GMT" /p:BuildSourceVersion="LWpfApplication2_20150615.3@$/Essai2" /p:BuildDefinition="WpfApplication2"


Run optional script after MSBuild00:00:00

InputsEnvironmentVariables: 
Enabled: True
Arguments: 
FilePath: 

OutputsResult: 0


Run optional script before Test Runner00:00:00

InputsEnvironmentVariables: 
Enabled: True
Arguments: 
FilePath: 

OutputsResult: 0


Run VS Test Runner00:00:00

InputsTestSpecs: BuildParameter[] Array
Enabled: False
ConfigurationsToTest: String[] Array
OutDir: 

This activity was not run since its Enabled property was set to False.


Run optional script after Test Runner00:00:25

InputsEnvironmentVariables: 
Enabled: True
Arguments: 
FilePath: C:\sonarqube\bin\SonarQube.MSBuild.Runner.exe

OutputsResult: 0

C:\sonarqube\bin\SonarQube.MSBuild.Runner.exe

Post-processing (no arguments passed)

Using environment variables to determine the download directory...

Using environment variable 'TF_BUILD_BUILDDIRECTORY', value 'C:\Builds\1\Essai2\WpfApplication2'

Executing file C:\Builds\1\Essai2\WpfApplication2\sqtemp\bin\SonarQube.MSBuild.PostProcessor.exe

Args:

Working directory: C:\Builds\1\Essai2\WpfApplication2\sqtemp\bin

Timeout (ms):3600000

Process id: 6548

01:45:28: Legacy TeamBuild environment detected

01:45:28: Loading the SonarQube analysis config from C:\Builds\1\Essai2\WpfApplication2\sqtemp\conf\SonarQubeAnalysisConfig.xml

01:45:28: Legacy TeamBuild environment detected

01:45:28: Attempting to locate the CodeCoverage.exe tool...

01:45:28: Code coverage command line tool: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe

01:45:28: Fetching code coverage report information from TFS...

01:45:28: Connecting to TFS...

01:45:29: Fetching build information...

01:45:30: Fetch code coverage report info...

01:45:52: Operation timed out, Elapsed time (ms): 20358

01:45:52: ...done.

01:45:52: No code coverage reports were found for the current build.

01:45:52: Generating SonarQube project properties file to C:\Builds\1\Essai2\WpfApplication2\sqtemp\out\sonar-project.properties

01:45:52: No ProjectInfo.xml files were found. Check that the analysis targets are referenced by the MSBuild projects being built.

01:45:52: Writing processing summary to C:\Builds\1\Essai2\WpfApplication2\sqtemp\out\ProjectInfo.log

01:45:52: Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.

01:45:52: Updating the TeamBuild summary...

Process returned exit code 1

 Exception Message: TF270015: 'SonarQube.MSBuild.Runner.exe' returned an unexpected exit code. Expected '0'; actual '1'. See the build logs for more details. (type UnexpectedExitCodeException) Exception Stack Trace: at System.Activities.Statements.Throw.Execute(CodeActivityContext context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation) 


Handle Exception

dun*_*anp 7

解决MSBuild.Runner v0.9的问题

提供以下信息是为了帮助解决MSBuild.Runner 0.9版的问题.在以后的版本中,行为可能会更改.

最严重的配置问题将导致出现在"构建摘要"页面上的警告或错误.如果没有报告错误或警告,请检查TFS TeamBuild诊断输出(单击Visual Studio中构建摘要报告顶部的"诊断"链接).处理前和处理后的步骤都记录了大量信息,以帮助诊断问题.

1.检查"构建摘要报告"中是否出现SonarQube分析摘要部分

该部分应如下所示:

SonarQube Analysis Summary
Analysis failed for SonarQube project "Simple console app", version 1.0
  Product projects: 4, test projects: 2
  Invalid projects: 0, skipped projects: 0, excluded projects: 0
Run Code Online (Sandbox Code Playgroud)

如果该部分未出现在构建摘要页面上,则构建代理,构建定义或两者都存在配置问题.请阅读以下步骤以进一步诊断这些步骤.

1.1检查摘要中报告的项目数

如果未找到任何项目,则表明在构建期间未导入和使用集成目标.

如果所有项目都标记为无效,则可能是您正在构建多个配置,例如[release or debug] | [x86或x64].您还应该收到一条错误消息,指出找不到ProjectInfo.xml文件.

您一次只能分析一个配置.如果要分析发布和调试版本,则需要使用不同的SonarQube项目ID为每个版本创建单独的构建定义.

诊断日志将包含有关项目无效原因的更多信息,这通常是因为项目没有guid,或者guid不是唯一的.非唯一guid的正常原因是您正在构建多个配置,例如发布和调试.

2.检查是否正在执行预构建步骤

诊断输出应包含类似于以下内容的输出:

在MSBuild之前运行可选脚本

C:\ SonarQube\bin\SonarQube.MSBuild.Runner.exe/key:MyProject/name:"My Project"/ version:1.0

预处理(传递3个参数)

如果没有,请检查您是否在构建定义的"预构建脚本"步骤中正确调用SonarQube.MSBuild.Runner.exe.一个简单的错误是通过设置"Post-build"属性将脚本参数放在错误的框中(无用的是,UI中的Post-build字段出现在Pre-build字段之前).

2.检查正在执行构建后步骤

诊断输出应包含类似于以下内容的输出:

在Test Runner之后运行可选脚本

C:\ SonarQube\BIN\SonarQube.MSBuild.Runner.exe

后处理(没有参数传递)

如果没有,请检查您是否在构建定义的"测试后脚本"步骤中正确调用SonarQube.MSBuild.Runner.exe.

3.检查诊断日志的其余部分

如果正确执行构建前和构建后步骤,请检查诊断输出的其余部分,以获取有关哪些不起作用的线索.特别注意来自前处理器和后处理器的有关它们正在写入的目录和文件的消息.

4.检查在构建代理程序上创建的文件

分析过程在v0.9中名为SQTemp的文件夹下的build目录下创建临时文件.检查文件夹的内容有助于确定分析失败的阶段.

预期的文件夹如下:

  • bin:此文件夹包含分析目标和二进制文件.它由SonarQube.MSBuild.Runner.exe创建,它从SonarQube服务器下载文件.如果此文件夹不存在或为空,则分析在很早的阶段就会失败,并且应该出现警告或错误.检查SonarQube服务器上是否正确安装了C#插件v4,以及自插件安装以来SonarQube是否已重新启动.

  • conf:此文件夹在预处理期间创建,包含从SonarQube服务器下载的设置.如果SonarQube中有任何活动的FxCop规则,则该文件夹应包含FxCop规则集.

  • out:在MSBuild阶段填充此文件夹.每个正在构建的项目应包含一个文件夹.它还将包含生成的sonar-project.properties文件,该文件将传递给声纳 - 跑步者.如果文件夹为空,则可能无法正确导入SonarQube.Integration.targets.在这种情况下,通常会出现错误消息"找不到ProjectInfo.xml文件".ProjectInfo.xml文件由SonarQube.Integration.targets中的目标"WriteSonarQubeData"生成,因此接下来要检查的是正确导入SonarQube.Integration.targets并且正在执行预期目标.

5.检查SonarQube.Integration.targets是否已导入并调用

首先,仔细检查SonarQube.Integration.ImportBefore.targets文件的安装:

  • 检查它是否在您正在使用的MSBuild版本的正确文件夹中,即%ProgramFiles(x86)%\ MSBuild\[12.0或14.0]\Microsoft.Common.Targets\ImportBefore
  • 检查文件夹名称"ImportBefore"中的拼写错误(应该是单数,而不是复数)(感谢BlackMarble的 Richard 提供此提示).

如果目标安装正确,那么您需要将MSBuild日志记录的详细程度增加到诊断并再次构建,以便您可以检查详细的MSBuild输出.不幸的是,在TeamBuild 2013下运行时,似乎没有一种简单的方法来增加MSBuild日志的详细程度.您可以生成一个包含更多详细信息的附加日志文件,但是您需要访问构建代理程序计算机才能获取日志文件.

要创建包含更详细信息的MSBuild日志:

  • 从Visual Studio的BUILD菜​​单中选择"Queue New Build"
  • 单击"参数"选项卡.
  • 展开"2. Build"部分和"5. Advanced"部分
  • 将"MSBuild arguments"属性设置为以下内容:/ m:1/fl2/flp2:"verbosity = diagnostic""/ m:1"告诉MSBuild不要并行构建,这样可以使日志更容易阅读.另外两个参数告诉MSBuild记录到文件.有关详细信息,请参阅MSBuild命令行帮助.
  • 单击"队列"并等待构建完成.
  • 在构建代理上查找并打开日志.它应该被称为msbuild2.log并位于构建定义的源目录下.

如果正在执行SonarQube.Intergration.ImportBefore.targets,则会有一个日志条目表示已执行"SonarQubeImportBeforeInfo"目标.应该有一些输出消息说明文件"SonarQube.Integration.targets"是否被找到.

ProjectInfo.xml文件由目标"WriteSonarQubeProjectData"编写.日志应显示已执行此目标,并且已执行"WriteProjectInfoFile"任务.如果没有,日志应该知道为什么跳过目标.