Reputation: 2043
I'm really not sure what's going on here.
I've got 2 issues.
First I installed the scanner dotnet tool install --global dotnet-sonarscanner
Then I tried to run dotnet sonarscanner begin /key:"mykey" /s:"./sonar-project.properties"
which gave me the following error message:
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.
Not sure why that is because I copied my file from here.
I then do dotnet scanner being /key:"mykey" /?
and it tells me I can use /d:sonar.verbose=true
. I immediatey try this command dotnet sonarscanner being /key:"mykey" /d:sonar.verbose=true
and am met with this error message.
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
I also try dotnet sonarscanner begin /key:"mykey" /d:sonar.host.url="https://sonar.qube"
but it's the same thing, it cannot recognise the argument.
Any ideas are welcome.
sonar.login=token
sonar.host=https://sonar.qube
sonar.projectKey=mykey
sonar.projectName=mykey
sonar.sourceEncoding=UTF-8
Upvotes: 3
Views: 4031
Reputation: 151
You have to change the '/k' for '-k'
dotnet sonarscanner begin -k:"proj_key" -d:sonar.host.url="http://myurl"
Upvotes: 12
Reputation: 71
If your problem still exists, can you share the properties file? I think you have the Java project file, and not the MSBuild file (which is an XML file, see: 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>
The example you link towards, is showing Java code and settings.
In the second issue you have, there is a typo:
dotnet sonarscanner being /key:"mykey" /d:sonar.verbose=true
should be
dotnet sonarscanner begin /key:"mykey" /d:sonar.verbose=true
Although i expect there was a second typo for the verbosity, looking at your console output. So, your command does not seem to reflect the output there.
For the final example you give, sonar is complaining about the URL, but other than that, the command line arguments are correct and working on my machine.
Upvotes: 0