Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用sonarQube分析c代码:MSBUILD版本问题_C#_Visual Studio_Msbuild_Sonarqube_Sonarqube Scan - Fatal编程技术网

C# 使用sonarQube分析c代码:MSBUILD版本问题

C# 使用sonarQube分析c代码:MSBUILD版本问题,c#,visual-studio,msbuild,sonarqube,sonarqube-scan,C#,Visual Studio,Msbuild,Sonarqube,Sonarqube Scan,我需要分析各种C#文件(不是项目,只是放在同一目录下的.cs文件) 我尝试了两种不同的分析方法,每种方法都有错误。有人能帮忙解决这些错误吗 1-我尝试了前面提到的分析 通过在根文件中执行C:\sonar scanner\bin\sonar-scanner.bat,我发现了这个错误 ERROR: Error during SonarQube Scanner execution java.lang.IllegalArgumentException: Custom and 3rd party Rosl

我需要分析各种C#文件(不是项目,只是放在同一目录下的.cs文件)

我尝试了两种不同的分析方法,每种方法都有错误。有人能帮忙解决这些错误吗

1-我尝试了前面提到的分析

通过在根文件中执行C:\sonar scanner\bin\sonar-scanner.bat,我发现了这个错误

ERROR: Error during SonarQube Scanner execution
java.lang.IllegalArgumentException: Custom and 3rd party Roslyn analyzers 
are only by MSBuild 14. Either use MSBuild 14, or disable the custom/3rd 
party Roslyn analyzers in your quality profile.
2-我厌倦了创建项目和分析

但最后,我出现了这个错误

The SonarQube MSBuild integration failed: SonarQube was unable to collect 
the required information about your projects.
Possible causes:
 1. The project has not been built - the project must be built in between 
the begin and end steps
 2. An unsupported version of MSBuild has been used to build the project. 
 Currently MSBuild 14.0 upwards are supported
 3. The begin, build or end steps have not all been launched from the 
 same folder
 Generation of the sonar-properties file failed. Unable to complete 
 SonarQube analysis.
我已安装Visual Studio 201520120102008。如何验证我使用的是正确的MSBUILD verison(14),因为我检查了C:\Program Files(x86)\MSBUILD,并在那里找到了版本14

还有其他问题要处理吗

最后,我需要能够以第一种和第二种方式进行分析

提前谢谢你

2-我厌倦了创建项目并使用SonarQube Scanner for MSBuild进行分析

根据文档,我们需要从要分析的项目的根文件夹执行以下命令:

SonarQube.Scanner.MSBuild.exe begin /k:"org.sonarqube:sonarqube-scanner-msbuild" /n:"Project Name" /v:"1.0"
MSBuild.exe /t:Rebuild
SonarQube.Scanner.MSBuild.exe end

但是命令MSBuild.exe是一个外部命令,Windows无法在任意目录中识别,您应该将MSBuild路径“C:\Program Files(x86)\MSBuild\14.0\Bin”添加到系统环境中以使开始、生成或结束步骤都从同一文件夹启动

第二种方式,这个项目是用VS2015创建的吗?如果是,则应将MSBuild路径“C:\Program Files(x86)\MSBuild\14.0\Bin”添加到系统环境中,以使开始、生成或结束步骤都从同一文件夹启动。它在我的机器上运行得很好。对于第一种方式,您能否与我们分享您如何配置它的详细步骤?如果没有详细的配置信息,我们无法复制第一个问题。非常感谢您的回答!我将msBuild路径添加为mentoined,错误已消失。尽管如此,我只需要分析一些.cs文件(我没有完整的项目),第二种方法听起来不可能。有关我的问题的更多详细信息,请参阅此问题链接。提前谢谢!很高兴知道这对你有帮助。我将评论转换为答案,您可以将其标记为答案,这样可以帮助其他社区成员解决同样的问题。我会继续调查你在评论中提到的问题,如果我有任何结果,我会在帖子中告诉你。