声纳和TFS 2013:找不到ProjectInfo.xml文件 [英] Sonar and TFS 2013 : No ProjectInfo.xml files were found

查看:65
本文介绍了声纳和TFS 2013:找不到ProjectInfo.xml文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

When I run TFS 2013 with sonar I get the following error: 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
  • sonar-csharp-plugin-4.0.jar
  • SonarQube.MSBuild.Runner-0.9.zip
  • sonar-runner-dist-2.4.zip

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

I've followed instructions found in "SonarQube Installation Guide for Existing TFS Environment.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)

这是诊断程序(我将源代码检出部分截断了):

Here is the Diagnostic (I truncated the source check out part) :



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

推荐答案

MSBuild.Runner v0.9的问题排查

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

Troubleshooting issues with the MSBuild.Runner v0.9

The following information is provided to help troubleshooting issues with version 0.9 of the MSBuild.Runner. The behaviour may change in later versions.

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

Most serious configuration issues will result in warnings or errors that will appear on the Build Summary page. In cases in which there are no errors or warnings reported, check the TFS TeamBuild diagnostic output (click on "Diagnostics" link at the top of the build summary report in Visual Studio). Both the pre- and post-processor steps log quite a lot of information to help diagnose issues.

该部分应如下所示:

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

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

If the section does not appear on the build summary page then there are configuration issues with the build agent, build definition, or both. Read the steps below to diagnose these further.

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

1.1 Check the number of projects that are reported in the summary

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

If no projects were found then it suggests that the integration targets are not being imported and used during the build.

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

If all of the projects are marked as invalid, it is likely that you are building more than one configuration e.g. [release or debug] | [x86 or x64]. You should also get an error saying no ProjectInfo.xml files could be found.

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

You can only analyse one configuration at a time. If you want to analyze both release and debug builds, then you will need to create a separate build definition for each, using different SonarQube project ids.

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

The diagnostic log will contain more infomation about why a project was invalid, which is normally because the project doesn't have a guid, or the guid is not unique. The normal reason for a non-unique guid is that you are building multiple configurations e.g. release and debug.

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

The diagnostic output should contain output similar to the following:

在MSBuild之前运行可选脚本

Run optional script before MSBuild

C:\ SonarQube \ bin \ SonarQube.MSBuild.Runner.exe/key:MyProject/名称:我的项目"/版本:1.0

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

预处理(传递了3个参数)

Pre-processing (3 arguments passed)

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

If it doesn't, check that the you are correctly calling SonarQube.MSBuild.Runner.exe in the "Pre-build script" step in the build definition. An easy mistake is to put the script parameters in the wrong box by setting the "Post-build" properties instead (unhelpfully, the Post-build fields in the UI appear before the Pre-build fields).

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

The diagnostic output should contain output similar to the following:

在测试运行器之后运行可选脚本

Run optional script after Test Runner

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

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

后处理(不传递任何参数)

Post-processing (no arguments passed)

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

If it doesn't, check that the you are correctly calling SonarQube.MSBuild.Runner.exe in the "Post-test script" step in the build definition.

如果正确执行了构建前和构建后步骤,请检查诊断输出的其余部分是否有任何不正常的线索.要特别注意预处理器和后处理器发出的有关其正在写入的目录和文件的消息.

If the pre- and post- build steps are being executed correctly, check the rest of the diagnostic output for any clues as to what isn't working. Pay particular attention to messages from the pre- and post-processor about the directories and files they are writing to.

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

The analysis process creates temporary files under the build directory under a folder called SQTemp in v0.9. Examining the contents of the folders can help determine the stage at which the analysis is failing.

预期的文件夹如下:

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

  • bin: this folder contains the analysis targets and binaries. It is created by the SonarQube.MSBuild.Runner.exe which downloads the files from the SonarQube server. If this folder does not exist or is empty then the analysis failed at a very early stage and there should warnings or errors. Check that the C# plugin v4 is installed correctly on the SonarQube server, and that the SonarQube has been restarted since the plugin was installed.

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

conf: this folder is created during pre-processing and contains the settings downloaded from the SonarQube server. If there are any FxCop rules active in the SonarQube the folder should contain an FxCop ruleset.

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

out: this folder is populated during the MSBuild phase. It should contain one folder per project being built. It will also contain the generated sonar-project.properties file that is passed to the sonar-runner. If the folder is empty then it is possible the SonarQube.Integration.targets are not being imported correctly. The error message "No ProjectInfo.xml files were found" will normally appear in this case. The ProjectInfo.xml files are generated by the target "WriteSonarQubeData" in the SonarQube.Integration.targets, so the next thing to check is that SonarQube.Integration.targets are being imported correctly and the expected targets are being executed.

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

Firstly, double-check the installation of the SonarQube.Integration.ImportBefore.targets file:

  • 检查它是否位于您正在使用的MSBuild版本的正确文件夹中,即%ProgramFiles(x86)%\ MSBuild \ [12.0或14.0] \ Microsoft.Common.Targets \ ImportBefore
  • 检查文件夹名称"ImportBefore"中的拼写错误(应为单数形式,不能为复数形式) (此提示感谢 BlackMarble 中的Richard).
  • check it is in the correct folder for the version of MSBuild you are using i.e. %ProgramFiles(x86)%\MSBuild\[12.0 or 14.0]\Microsoft.Common.Targets\ImportBefore
  • check for typos in the folder name "ImportBefore" (should be singular, not plural) (Thanks to Richard from BlackMarble for this tip).

如果目标安装正确,那么您将需要增加MSBuild日志记录的详细程度以进行诊断并重新构建,以便可以检查详细的MSBuild输出.不幸的是,在TeamBuild 2013下运行时,似乎没有一种简单的方法可以提高MSBuild日志的详细程度.您可以生成一个具有更多详细信息的附加日志文件,但需要访问build agent机器才能进行日志文件.

If the targets are installed correctly then you will need to increase the verbosity of the MSBuild logging to diagnostic and build again so you can check the detailed MSBuild output. Unfortunately, there doesn't seem to be a simple way to increase the verbosity of the MSBuild logs when running under TeamBuild 2013. You can produce an additional log file with more detail, but you will need access to the build agent machine to pick up the log file.

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

To create an MSBuild log with more detailed info:

  • 从Visual Studio的BUILD菜​​单中选择排队新版本"
  • 单击参数"标签.
  • 展开"2.构建"部分和"5.高级"部分
  • 将"MSBuild参数"属性设置为以下内容: /m:1/fl2/flp2:详细程度=可诊断" "/m:1"告诉MSBuild不要并行构建,这可以使日志更易于阅读.其他两个参数告诉MSBuild记录到文件.有关更多信息,请参见MSBuild命令行帮助.
  • 单击队列",然后等待构建完成.
  • 在构建代理上找到并打开日志.它应名为msbuild2.log,并在您的构建定义的源目录下.
  • select "Queue New Build" from the BUILD menu in Visual Studio
  • click on the "Parameters" tab.
  • Expand the "2. Build" section and the "5. Advanced" sections
  • Set the "MSBuild arguments" property to the following: /m:1 /fl2 /flp2:"verbosity=diagnostic" The "/m:1" tells MSBuild not to build in parallel which can make the log easier to read. The other two parameters tell MSBuild to log to a file. See the MSBuild command line help for more info.
  • Click "Queue" and wait for the build to finish.
  • Find and open the log on the build agent. It should be called msbuild2.log and be under the source directory for your build definition.

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

If the SonarQube.Intergration.ImportBefore.targets are being executed, there will be a log entry saying the "SonarQubeImportBeforeInfo" target was executed. There should be some output message saying whether the file "SonarQube.Integration.targets" was located or not.

ProjectInfo.xml文件由目标"WriteSonarQubeProjectData"编写.日志应显示该目标已执行,并且"WriteProjectInfoFile"任务已执行.如果不是,则日志应说明为什么跳过了目标.

The ProjectInfo.xml files are written by the target "WriteSonarQubeProjectData". The log should show that this target has been executed, and the "WriteProjectInfoFile" task has executed. If not, the log should give an idea of why the targets were skipped.

这篇关于声纳和TFS 2013:找不到ProjectInfo.xml文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆