我真的不确定这里发生了什么。
我有2个问题。
首先我安装了扫描仪dotnet tool install --global dotnet-sonarscanner
然后我尝试运行dotnet sonarscanner begin /key:"mykey" /s:"./sonar-project.properties"
,该错误消息告诉我:
SonarScanner for MSBuild 4.6
Using the .NET Core version of the Scanner for MSBuild
Loading analysis properties from path\sonar-project.properties
Unable to read the SonarQube analysis settings file 'path\sonar-project.properties'. Please fix the content of this file.
不确定为什么是因为我从here复制了文件。
然后我做dotnet scanner being /key:"mykey" /?
,它告诉我可以使用/d:sonar.verbose=true
。我立即尝试使用此命令dotnet sonarscanner being /key:"mykey" /d:sonar.verbose=true
,并遇到此错误消息。
22:39:19.402 22:39:19.399 Unrecognized command line argument: being
22:39:19.403 22:39:19.4 Unrecognized command line argument: d:sonar.verbose=true
22:39:19.404 Expecting at least the following command line argument:
- SonarQube project key
When connecting to a SonarQube server earlier than version 6.1, the following command line arguments are also required:
- SonarQube project name
- SonarQube project version
The full path to a settings file can also be supplied. If it is not supplied, the exe will attempt to locate a default settings file in the same directory as the SonarQube Scanner for MSBuild.
Use '/?' or '/h' to see the help message.
22:39:19.405 Pre-processing failed. Exit code: 1
我也尝试dotnet sonarscanner begin /key:"mykey" /d:sonar.host.url="https://sonar.qube"
,但这是同一件事,它无法识别参数。
欢迎提出任何想法。
sonar.login=token
sonar.host=https://sonar.qube
sonar.projectKey=mykey
sonar.projectName=mykey
sonar.sourceEncoding=UTF-8
答案 0 :(得分:0)
如果问题仍然存在,可以共享属性文件吗?我认为您拥有Java项目文件,而不是MSBuild文件(这是XML文件,请参见:https://docs.sonarqube.org/display/SCAN/Additional+Analysis+Parameters)。
<?xml version="1.0" encoding="utf-8" ?>
<SonarQubeAnalysisProperties
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.sonarsource.com/msbuild/integration/2015/1">
<Property Name="sonar.verbose">true</Property>
</SonarQubeAnalysisProperties>
您链接到的示例显示了Java代码和设置。
在第二期中,有一个错字:
dotnet sonarscanner being /key:"mykey" /d:sonar.verbose=true
应该是
dotnet sonarscanner begin /key:"mykey" /d:sonar.verbose=true
尽管我希望再详细一点,但要看您的控制台输出。因此,您的命令似乎无法反映那里的输出。
对于您给出的最后一个示例,声纳正在抱怨URL,但除此之外,命令行参数是正确的并且可以在我的机器上工作。
答案 1 :(得分:0)
您必须将'/ k'更改为'-k'
dotnet sonarscanner begin -k:"proj_key" -d:sonar.host.url="http://myurl"