Can anyone help with this error please? I’m attempting to get started with running the .net framework scanner on local sonarqube instance to trial run this product.
SonarQube
deployed: zip (Local)
Running .net framework scanner
I’ve installed sonarqube and logged in. Then updated admin password, created project and created token via http://localhost:9000/
I downloaded and installed the .net framework scanner and I’m trying to get it to run now
C:\repo01\GBE_ROOT_WEB\GBET.yyy.zzz>SonarScanner.MSBuild.exe begin /k:“BE” /d:sonar.host.url=“http://localhost:9000” /d:sonar.token=“sqp_xxxxxxx”
SonarScanner for MSBuild 8.0
Using the .NET Framework version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories…
10:28:34.273 Updating build integration targets…
10:28:34.544 10:28:34.544 WARNING: Authentication with the server has failed.
10:28:34.546 10:28:34.546 WARNING: In version 7 of the scanner, the default value for the sonar.host.url changed from “http://localhost:9000” to “https://sonarcloud.io”.
If the intention was to connect to the local SonarQube instance, please add the parameter: /d:sonar.host.url=“http://localhost:9000”
10:28:34.548 Pre-processing failed. Exit code: 1
I’m guessing that there’s a mismatch between the project key you provided server-side at project creation and the one on the commandline and/or a copy/paste flub with the token.
That sqp token prefix tells me the token is project-specific, so if the keys don’t match, an auth error would be expected.
I created a new project and generated a new token, I then added that token to the following file : C:\sonar-scanner-8.0.0.97025-net-framework\SonarQube.Analysis.xml
Within Property Name=“sonar.token” I set mytoken
Is this correct?
I use the commands as displayed in the SonarQube UI
“Execute the Scanner
Running a SonarQube analysis is straightforward. You just need to execute the following commands at the root of your solution.”
3 commands are listed on UI
SonarScanner.MSBuild.exe begin /k:“myprj” /d:sonar.host.url=http://localhost:9000 /d:sonar.token=“mytoken”
….
I copy/paste these to the command line at location of solution. First command causes the error.
The .net global scanner works on our newer/later .net version solutions without issue. This issue is the .net framework scanner on 4.8 solutions.
Install Steps I followed
I downloaded/unzipped the .net framework scanner and added the directory containing SonarScanner.MSBuild.exe to the %PATH% environment variable.
That’s not a good place for a project-specific token. That file provides build-agent defaults. That’s where you would set, e.g. sonar.host.url, i.e. values that apply universally to all analyses of all projects.
Are you actually running analysis on the same machine where SonarQube is running? That’s the only time a sonar.host.url=http://localhost:9000 parameter is appropriate. Otherwise, you should use the URL of your SonarQube instance there.
Adding the token to the SonarQube.Analysis.xml file
I’ve removed this now
Still I have the same issue
2)Are you actually running analysis on the same machine where SonarQube is running?
Yes its running locally.
Thank you .Command line output below.
Nothing of note in logs at C:\sonarqube\sonarqube-10.6.0.92116\logs but I can add if needed.
C:\repo01\GBE_ROOT_WEB\GBET.Exchange.Website\trunk\src\GBET.Exchange.Website>SonarScanner.MSBuild.exe begin /d:"sonar.verbose=true" /k:"gbet.exchange.website" /d:sonar.host.url="http://localhost:9000" /d:sonar.token="sqp_*removingmytoken*"
SonarScanner for MSBuild 8.0
Using the .NET Framework version of the Scanner for MSBuild
Default properties file was found at C:\sonar-scanner-8.0.0.97025-net-framework\SonarQube.Analysis.xml
Loading analysis properties from C:\sonar-scanner-8.0.0.97025-net-framework\SonarQube.Analysis.xml
sonar.verbose=true was specified - setting the log verbosity to 'Debug'
Pre-processing started.
Preparing working directories...
Using environment variables to determine the download directory...
14:00:08.79 14:00:08.764 Loading analysis properties from C:\sonar-scanner-8.0.0.97025-net-framework\SonarQube.Analysis.xml
14:00:08.794 14:00:08.777 Server Url: http://localhost:9000
14:00:08.794 14:00:08.777 Api Url: http://localhost:9000/api/v2
14:00:08.794 14:00:08.777 Is SonarCloud: False
14:00:08.796 14:00:08.79 sonar.verbose=true was specified - setting the log verbosity to 'Debug'
14:00:08.799 Updating build integration targets...
14:00:08.803 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\ywalshe\AppData\Local\Microsoft\MSBuild\4.0\Microsoft.Common.targets\ImportBefore
14:00:08.807 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\ywalshe\AppData\Local\Microsoft\MSBuild\10.0\Microsoft.Common.targets\ImportBefore
14:00:08.808 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\ywalshe\AppData\Local\Microsoft\MSBuild\11.0\Microsoft.Common.targets\ImportBefore
14:00:08.809 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\ywalshe\AppData\Local\Microsoft\MSBuild\12.0\Microsoft.Common.targets\ImportBefore
14:00:08.81 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\ywalshe\AppData\Local\Microsoft\MSBuild\14.0\Microsoft.Common.targets\ImportBefore
14:00:08.81 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\ywalshe\AppData\Local\Microsoft\MSBuild\15.0\Microsoft.Common.targets\ImportBefore
14:00:08.812 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\ywalshe\AppData\Local\Microsoft\MSBuild\Current\Microsoft.Common.targets\ImportBefore
14:00:08.819 Installed SonarQube.Integration.targets to C:\repo01\GBE_ROOT_WEB\GBET.Exchange.Website\trunk\src\GBET.Exchange.Website\.sonarqube\bin\targets
14:00:08.824 Creating config and output folders...
14:00:08.825 Creating directory: C:\repo01\GBE_ROOT_WEB\GBET.Exchange.Website\trunk\src\GBET.Exchange.Website\.sonarqube\conf
14:00:08.826 Creating directory: C:\repo01\GBE_ROOT_WEB\GBET.Exchange.Website\trunk\src\GBET.Exchange.Website\.sonarqube\out
14:00:08.875 Downloading from http://localhost:9000/api/settings/values?component=unknown...
14:00:09.085 Response received from http://localhost:9000/api/settings/values?component=unknown...
14:00:09.088 14:00:09.088 WARNING: Authentication with the server has failed.
14:00:09.088 14:00:09.088 WARNING: In version 7 of the scanner, the default value for the sonar.host.url changed from "http://localhost:9000" to "https://sonarcloud.io".
If the intention was to connect to the local SonarQube instance, please add the parameter: /d:sonar.host.url="http://localhost:9000"
14:00:09.089 Pre-processing failed. Exit code: 1
C:\repo01\GBE_ROOT_WEB\GBET.Exchange.Website\trunk\src\GBET.Exchange.Website>
Thank you for your reply. I only replaced my token value. I’ve rerun this am and all output as is, is below.
Thanks,
Yvonne
C:\repo01\GBE_ROOT_WEB\GBET.Exchange.Website\trunk\src\GBET.Exchange.Website>SonarScanner.MSBuild.exe begin /k:"gbet.exchange.website" /d:"sonar.verbose=true" /d:sonar.host.url="http://localhost:9000" /d:sonar.token="sqp_7b349605bb4c3aa782214ecc47bc1aed969d0169"
SonarScanner for MSBuild 8.0
Using the .NET Framework version of the Scanner for MSBuild
Default properties file was found at C:\sonar-scanner-8.0.0.97025-net-framework\SonarQube.Analysis.xml
Loading analysis properties from C:\sonar-scanner-8.0.0.97025-net-framework\SonarQube.Analysis.xml
sonar.verbose=true was specified - setting the log verbosity to 'Debug'
Pre-processing started.
Preparing working directories...
Using environment variables to determine the download directory...
14:04:29.805 14:04:29.702 Loading analysis properties from C:\sonar-scanner-8.0.0.97025-net-framework\SonarQube.Analysis.xml
14:04:29.807 14:04:29.767 Server Url: http://localhost:9000
14:04:29.807 14:04:29.767 Api Url: http://localhost:9000/api/v2
14:04:29.808 14:04:29.767 Is SonarCloud: False
14:04:29.809 14:04:29.805 sonar.verbose=true was specified - setting the log verbosity to 'Debug'
14:04:29.814 Updating build integration targets...
14:04:29.838 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\ywalshe\AppData\Local\Microsoft\MSBuild\4.0\Microsoft.Common.targets\ImportBefore
14:04:29.841 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\ywalshe\AppData\Local\Microsoft\MSBuild\10.0\Microsoft.Common.targets\ImportBefore
14:04:29.844 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\ywalshe\AppData\Local\Microsoft\MSBuild\11.0\Microsoft.Common.targets\ImportBefore
14:04:29.85 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\ywalshe\AppData\Local\Microsoft\MSBuild\12.0\Microsoft.Common.targets\ImportBefore
14:04:29.882 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\ywalshe\AppData\Local\Microsoft\MSBuild\14.0\Microsoft.Common.targets\ImportBefore
14:04:29.887 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\ywalshe\AppData\Local\Microsoft\MSBuild\15.0\Microsoft.Common.targets\ImportBefore
14:04:29.89 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\ywalshe\AppData\Local\Microsoft\MSBuild\Current\Microsoft.Common.targets\ImportBefore
14:04:29.938 Installed SonarQube.Integration.targets to C:\repo01\GBE_ROOT_WEB\GBET.Exchange.Website\trunk\src\GBET.Exchange.Website\.sonarqube\bin\targets
14:04:29.942 Creating config and output folders...
14:04:29.944 Creating directory: C:\repo01\GBE_ROOT_WEB\GBET.Exchange.Website\trunk\src\GBET.Exchange.Website\.sonarqube\conf
14:04:29.946 Creating directory: C:\repo01\GBE_ROOT_WEB\GBET.Exchange.Website\trunk\src\GBET.Exchange.Website\.sonarqube\out
14:04:30.042 Downloading from http://localhost:9000/api/settings/values?component=unknown...
14:04:30.284 Response received from http://localhost:9000/api/settings/values?component=unknown...
14:04:30.286 14:04:30.286 WARNING: Authentication with the server has failed.
14:04:30.288 14:04:30.288 WARNING: In version 7 of the scanner, the default value for the sonar.host.url changed from "http://localhost:9000" to "https://sonarcloud.io".
If the intention was to connect to the local SonarQube instance, please add the parameter: /d:sonar.host.url="http://localhost:9000"
14:04:30.289 Pre-processing failed. Exit code: 1
C:\repo01\GBE_ROOT_WEB\GBET.Exchange.Website\trunk\src\GBET.Exchange.Website>
Hey @ywalshe,
Can you create a Global Analysis Token and try again with that?
As a side note, since it’s a common misconception:
The .net global scanner works on our newer/later .net version solutions without issue. This issue is the .net framework scanner on 4.8 solutions.
The Scanner for .NET is fully compatible with .NET Framework projects. The only reason to use the old Scanner for MSBuild is, if you don’t have a modern version of .NET installed on the build machine.
Does anyone have a solution for this issue.
I am getting exactly the same thing.
The interesting part is the message returned just before getting exception: http://localhost:9000/api/settings/values?component=unknown
Tried using in browser and of course doesnt work.
However, if the component=unknown querystring is removed and sonar.logon=admin&sonar.password=… then it comes back with a page of key/values
Dont know if means anything or im just whistling in the dark!
Look at the server logs, C:\sonarqube\sonarqube-10.6.0.92116\logs\access.log in particular.
Ping the server via curl: curl --header 'Authorization: Bearer <token>' -i 'http://localhost:9000/api/settings/values?component=unknown'
The expected answer would be 404. If you get 401 or 403, something is wrong with your authentication/authorization.
Hi Bob,
I used the newer .Net scanner and that worked with my .net framework solution for this first step.
(After the first step you may need to use msbuild rather than dotnet build for the second step).
Hi Yvonne,
Downloaded latest and now it works.
One difference is first time I had edited the SonarQube.Analysis.xml that is in the net framework.
I had set the url, loginid and password.
This time I left that section commented out.
Wonder if that was issue.
Ah well.