SonarScanner for .NET - Version string portion was too short or too long

I am using sonar-scanner-msbuild-4.8.0.12008-net46 and running below command to start the analysis on Windows server 2012

C:\Users\Administrator\NuGet.devops\tools\MSBuild.SonarQube.Runner.Tool.4.8.0\tools\sonar-scanner-msbuild-4.8.0.12008-net46\SonarScanner.MSBuild.exe begin /k:“sonarqubeProject” /d:sonar.host.url=“https://sonarqube.myinstance.com” /d:sonar.login=“f9f523ab24269907bc2d6b3daaca66e103e2b3abb”

But getting below error :

Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Users\Administrator>C:\Users\Administrator\NuGet.devops\tools\MSBuild.SonarQ
ube.Runner.Tool.4.8.0\tools\sonar-scanner-msbuild-4.8.0.12008-net46\SonarScanner
.MSBuild.exe begin /k:“sonarqubeProject” /d:sonar.host.url=“https:
//sonarqube.myinstance.com” /d:sonar.login=“f9f523ab24269907bc2d6b3daaca66e103e2b3abb”
SonarScanner for MSBuild 4.8
Using the .NET Framework version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories…
06:41:08.988 Updating build integration targets…
06:41:09.019 Fetching analysis configuration settings…
06:41:09.277 Failed to request and parse ‘https://sonarqube.myinstance.com/api/server/version’: Version string portion was too short or too long.

Unhandled Exception: System.ArgumentException: Version string portion was too sh
ort or too long.
at System.Version.VersionResult.SetFailure(ParseFailureKind failure, String a
rgument)
at System.Version.TryParseVersion(String version, VersionResult& result)
at System.Version.Parse(String input)
at System.Version…ctor(String version)
at SonarScanner.MSBuild.PreProcessor.SonarWebService.<>c__DisplayClass15_0.b__0()
at SonarScanner.MSBuild.PreProcessor.SonarWebService.DoLogExceptions[T](Func 1 op, String url, Action1 onError)
at SonarScanner.MSBuild.PreProcessor.SonarWebService.DownloadServerVersion()
at SonarScanner.MSBuild.PreProcessor.SonarWebService.GetServerVersion()
at SonarScanner.MSBuild.PreProcessor.SonarWebService.GetProperties(String pro
jectKey, String projectBranch)
at SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.FetchArgumentsAndR
ulesets(ISonarQubeServer server, ProcessedArgs args, TeamBuildSettings settings,
IDictionary2& serverSettings, List1& analyzersSettings)
at SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.DoExecute(Processe
dArgs localSettings)
at SonarScanner.MSBuild.BootstrapperClass.PreProcess()
at SonarScanner.MSBuild.BootstrapperClass.Execute()
at SonarScanner.MSBuild.Program.Execute(String args, ILogger logger)
at SonarScanner.MSBuild.Program.Main(String args)

Hello @csb and welcome to the SonarSource community.

Your problem seem very similar to Version string portion was too short or too long on sonarcloud - #7 by VuHuong , can you check this ?

Also:

  • Do you comply to the Scanner for MSBuild prerequisites. I see that your run the Scanner on Windows Server 2012 which is pretty old. I would not be surprised that the VS or MSBuild version is too old too.

Then, can you check:

  • Is your SonarQube URL correct ?
  • Is your token correct ?
  • Can you pass properties as /d:"sonar.host.url=https://sonarqube.myinstance.com" and /d:"sonar.login=f9f523ab24269907bc2d6b3daaca66e103e2b3abb" (double quotes exactly where mine are located, not like what you did)

If still not working, please send me again the scanner execution in debug mode (add /d:sonar.verbose=true)

Olivier

1 Like

Hey Thanks Olivier for responding to the query.

In the build machine , i have below components

  1. dot net framework 4.7.2 sdk

  2. Java 8

  3. I have generated the token from sonarqube instance which is running behind the cloudflare.
    For cloudflare , i have received mTls certificates ( Client.pem and client-key.pem).

  4. TOKEN and URL are correct as I have one observation which i found when i added these certificates on POSTMAN and send the below url which is throwing specified error when I am running from command prompt i.e.
    https://sonarqube.myinstance.com/api/server/version

I am able to receive the result as below :
8.9.1.44547

But when without certificate I am seeing below error on hitting the same url :

Sign in ・ Cloudflare Access *{-webkit-box-sizing:inherit;box-sizing:inherit}body,html{min-height:100vh}html{background:#f7f7f8;text-align:center;text-rendering:optimizeLegibility;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";line-height:1.5;word-wrap:break-word;-webkit-box-sizing:border-box;box-sizing:border-box;background:#eee;color:#333}.Content,body{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}body{padding:32px 8px;margin:0}.Content{-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;margin:32px;-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1}@media screen and (max-width:425px){.Content{padding:0;margin:32px 0}}.AuthBox{max-width:100%;background:#fff;border:1px solid #eaebeb;-webkit-box-shadow:0 4px 8px rgba(146,151,155,.15);box-shadow:0 4px 8px rgba(146,151,155,.15);padding-top:2em;width:36em}.base_AccessLogo{margin-bottom:1em}.base_TeamsLogo{padding-top:1em;padding-bottom:2em}@media only screen and (max-width:420px) and (pointer:coarse){.base_AccessLogo{margin-top:1em}.base_TeamsLogo{padding:1em 0}}.Content{margin-top:8px}.AuthBox{border-radius:5px;margin-top:0;margin-bottom:0}.AuthBox .AuthBox-error-box-footer{border-radius:5px 0 .5em .5em;background:rgba(0,0,0,.03);border-top:1px solid rgba(0,0,0,.15)}.AuthBox .AuthBoxRow--name{text-transform:capitalize;font-size:15px;white-space:nowrap;overflow:hidden;-o-text-overflow:ellipsis;text-overflow:ellipsis;display:block}.AuthBox-RequestCode{border-bottom-left-radius:5px;border-bottom-right-radius:5px;padding-bottom:2.5em}.AuthBox-RequestCode__idpsExist{background:#f7f7f8}.AuthBox-error-box-footer{border:0;border-radius:5px;margin-bottom:2rem}.ErrorBlock,.ErrorBlock-icon{display:-webkit-box;display:-ms-flexbox;display:flex}.ErrorBlock-icon{width:2.25em;height:2.25em;margin-right:1.25em}.ErrorBlock-icon>svg{display:block;height:100%;width:100%}.ErrorBlock-body{-webkit-box-flex:1;-ms-flex:1;flex:1}.ErrorBlock-header-text{font-size:1.4em;margin-bottom:.5em}.JSONBlock{display:block;font-size:.9em;margin:0;padding:1.5em;font-family:Monaco,"Bitstream Vera Sans Mono","Lucida Console",Terminal,monospace;overflow-x:scroll;-webkit-overflow-scrolling:touch;color:rgba(0,0,0,.6)}.AuthBox-text{color:#4a4a4a;font-size:1.25em;font-weight:600;padding-top:1em;margin-bottom:24px}.AuthServiceLogin .AuthServiceLogin-row{padding-bottom:1em}.AuthFormLogin-row{text-align:left;margin:auto;max-width:22em;padding:1em 8px 0}.Footer-text,.Header-text{padding:3em 1em 1em;font-size:12px;line-height:18px}.Footer-text{padding:1em}.Footer-text span{white-space:pre-line}label{display:block;font-weight:600;margin-bottom:.5em}.Button{position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-appearance:none;-moz-appearance:none;appearance:none;display:inline-block;cursor:pointer;text-decoration:none;font:inherit;color:#fff;background:#333;padding:.5em 0;border:0;margin:0;border-radius:5px}.Button.Button-uses-org-theme-accent-color{background-color:#2c7cb0;padding:0 8px;width:100%}.Button:hover{-webkit-box-shadow:inset 0 0 0 999em rgba(255,255,255,.2);box-shadow:inset 0 0 0 999em rgba(255,255,255,.2)}.Button.Button-is-juicy{border-radius:5px;padding-top:.75em;padding-bottom:.75em;max-width:14em;font-weight:300}.Button.Button-is-block{display:block;margin:auto}.Button.Button-is-auth{background-color:#f7f7f8;border:1px solid #d5d7d8;color:inherit;text-align:left;min-height:55px;margin:0 3.5em;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-ms-flex-wrap:inherit;flex-wrap:inherit;padding-left:.5em}.Button.Button-is-auth .Button-auth-service-icon{width:2.8em;height:auto;padding:.5em;color:#1d1f20;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}.Button.Button-is-auth .Button-auth-service-icon>svg{fill:currentColor;display:block;min-width:25px;width:25px;height:25px}.Button.Button-uses-org-theme-accent-color{margin:0;max-width:unset}.AuthBox-messages{max-width:36em}.Button.Button-is-auth .Button-auth-service-icon,.Message,.RayID{display:-webkit-box;display:-ms-flexbox;display:flex}.Message{-webkit-box-align:center;-ms-flex-align:center;align-items:center;font-size:.9em;overflow:hidden;margin-bottom:1em;border-radius:5px;padding:.5em 1em;text-align:left}.Message svg{height:1em;width:1em;margin-right:.5em}.Message.Message-is-warning{background:#fcf0f2;color:#711423;border:1px solid #f3bac3}.Message.Message-is-success{background:#a6eac9;color:#1c422b;border:1px solid #b0ddc2}.RayID{padding:0;text-align:center;background:#dfbd9f}.RayID.RayID-Title,.RayID.RayID-Value{-webkit-box-flex:0;-ms-flex:0 0 auto;flex:0 0 auto;padding:1em;display:inline-block}.RayID.RayID-Value{background:#e7c9af;-webkit-box-flex:1;-ms-flex:1 1 auto;flex:1 1 auto;font-family:Monaco,"Bitstream Vera Sans Mono","Lucida Console",Terminal,monospace}.StandardInput{position:relative;-webkit-user-select:auto;-moz-user-select:auto;-ms-user-select:auto;user-select:auto;-webkit-appearance:none;-moz-appearance:none;appearance:none;display:inline-block;text-align:left;font:inherit;color:"#333333";padding:.5em 1em;border:1px solid #cacaca;margin:0;border-radius:5px}.StandardInput:focus{outline:0;border-color:#777}.StandardInput.StandardInput-is-block{display:block;font-size:1em;width:100%}.StandardInput.StandardInput-is-code{font-family:Monaco,"Bitstream Vera Sans Mono","Lucida Console",Terminal,monospace}.StandardInput.StandardInput-is-entry-code{font-size:20px}.StandardInput:-moz-placeholder,.StandardInput::-webkit-input-placeholder{font-family:inherit}.OrgAvatarLink{display:block;text-decoration:none;color:inherit}.OrgAvatarLink-logo img{margin-bottom:.5em}.App-name,.OrgAvatarLink-title{text-align:center;font-weight:200}.OrgAvatarLink-title{color:#4e5255;font-size:.8em}.App-name{font-size:1.5em}@media screen and (max-width:650px){.Button.Button-is-auth{margin:0 8px}.AuthFormLogin .AuthFormLogin-row{width:auto}.Content{margin:8px 0}}
  1. I will share the scanner execution in debug mode asap.

  2. Is there any way to check that user which has generated token has “Execute analysis” right???

below is the scanner execution in debug mode (add /d:sonar.verbose=true )

C:\newfeaturedev\Source\Solutions>C:\Users\Administrator\NuGet.devops\tools\MSB
uild.SonarQube.Runner.Tool.4.8.0\tools\sonar-scanner-msbuild-4.8.0.12008-net46\S
onarScanner.MSBuild.exe begin /k:“sonarqubeProject” /d:“sonar.host.url
=https://sonarqube.myinstance.com” /d:“sonar.login=f9f5cab24269907bc
2d6b3daaca66e103e2b3abb” /d:sonar.verbose=true
SonarScanner for MSBuild 4.8
Using the .NET Framework version of the Scanner for MSBuild
Default properties file was found at C:\Users\Administrator\NuGet.devops\tools
MSBuild.SonarQube.Runner.Tool.4.8.0\tools\sonar-scanner-msbuild-4.8.0.12008-net4
6\SonarQube.Analysis.xml
Loading analysis properties from C:\Users\Administrator\NuGet.devops\tools\MSBu
ild.SonarQube.Runner.Tool.4.8.0\tools\sonar-scanner-msbuild-4.8.0.12008-net46\So
narQube.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…
17:19:40.579 17:19:40.564 Loading analysis properties from C:\Users\Administra
tor\NuGet.devops\tools\MSBuild.SonarQube.Runner.Tool.4.8.0\tools\sonar-scanner-
msbuild-4.8.0.12008-net46\SonarQube.Analysis.xml
17:19:40.579 17:19:40.579 sonar.verbose=true was specified - setting the log v
erbosity to ‘Debug’
17:19:40.579 Updating build integration targets…
17:19:40.595 The file SonarQube.Integration.ImportBefore.targets is up to date
at C:\Users\Administrator\AppData\Local\Microsoft\MSBuild\4.0\Microsoft.Common.t
argets\ImportBefore
17:19:40.595 The file SonarQube.Integration.ImportBefore.targets is up to date
at C:\Users\Administrator\AppData\Local\Microsoft\MSBuild\10.0\Microsoft.Common.
targets\ImportBefore
17:19:40.595 The file SonarQube.Integration.ImportBefore.targets is up to date
at C:\Users\Administrator\AppData\Local\Microsoft\MSBuild\11.0\Microsoft.Common.
targets\ImportBefore
17:19:40.595 The file SonarQube.Integration.ImportBefore.targets is up to date
at C:\Users\Administrator\AppData\Local\Microsoft\MSBuild\12.0\Microsoft.Common.
targets\ImportBefore
17:19:40.595 The file SonarQube.Integration.ImportBefore.targets is up to date
at C:\Users\Administrator\AppData\Local\Microsoft\MSBuild\14.0\Microsoft.Common.
targets\ImportBefore
17:19:40.595 The file SonarQube.Integration.ImportBefore.targets is up to date
at C:\Users\Administrator\AppData\Local\Microsoft\MSBuild\15.0\Microsoft.Common.
targets\ImportBefore
17:19:40.595 The file SonarQube.Integration.ImportBefore.targets is up to date
at C:\Users\Administrator\AppData\Local\Microsoft\MSBuild\Current\Microsoft.Comm
on.targets\ImportBefore
17:19:40.595 Installed SonarQube.Integration.targets to C:\newfeaturedev\Source
\Solutions.sonarqube\bin\targets
17:19:40.595 Creating config and output folders…
17:19:40.595 Creating directory: C:\newfeaturedev\Source\Solutions.sonarqube\c
onf
17:19:40.595 Creating directory: C:\newfeaturedev\Source\Solutions.sonarqube\o
ut
17:19:40.611 Fetching analysis configuration settings…
17:19:40.626 Downloading from https://sonarqube.myinstance.com/api/
server/version…
17:19:41.23 Failed to request and parse ‘https://sonarqube.rosetta.ericssondevo
ps.com/api/server/version’: Version string portion was too short or too long.

Unhandled Exception: System.ArgumentException: Version string portion was too sh
ort or too long.
at System.Version.VersionResult.SetFailure(ParseFailureKind failure, String a
rgument)
at System.Version.TryParseVersion(String version, VersionResult& result)
at System.Version.Parse(String input)
at System.Version…ctor(String version)
at SonarScanner.MSBuild.PreProcessor.SonarWebService.<>c__DisplayClass15_0.b__0()
at SonarScanner.MSBuild.PreProcessor.SonarWebService.DoLogExceptions[T](Func 1 op, String url, Action1 onError)
at SonarScanner.MSBuild.PreProcessor.SonarWebService.DownloadServerVersion()
at SonarScanner.MSBuild.PreProcessor.SonarWebService.GetServerVersion()
at SonarScanner.MSBuild.PreProcessor.SonarWebService.GetProperties(String pro
jectKey, String projectBranch)
at SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.FetchArgumentsAndR
ulesets(ISonarQubeServer server, ProcessedArgs args, TeamBuildSettings settings,
IDictionary2& serverSettings, List1& analyzersSettings)
at SonarScanner.MSBuild.PreProcessor.TeamBuildPreProcessor.DoExecute(Processe
dArgs localSettings)
at SonarScanner.MSBuild.BootstrapperClass.PreProcess()
at SonarScanner.MSBuild.BootstrapperClass.Execute()
at SonarScanner.MSBuild.Program.Execute(String args, ILogger logger)

Hello @csb,

Did you add the certificate to the truststore of the JDK running SonarQube ?

Olivier

Hello Olivier,

Thanks for replying. No i am not aware of that. Do i need to add client.pem and client-key.pem files to below path :slight_smile:
C:\Program Files\Java\jre1.8.0_291\lib\security

BR
Chandra

This is beyond what we can give assistance for since this is not SonarQube related but rather simply Java related (any web app would have the same problem). You may google that, plenty of references, for instance How to import a .cer certificate into a java keystore? - Stack Overflow

Unrelated: I also see that you use Java 8. I strongly recommend you to plan for Java 11 migration ASAP. Starting with SonarQube 9.0 (released yesterday) we we’ll drop the support of Java 8, for server and scanner, since is was deprecated since a while now.

Hello Olivier,

we added the certificate to the java trusted store also to verify we checked with below command and newly added certificate is added:
keytool.exe -list -keystore cacerts -alias mycertp

But still we have the same issue

Well, I still believe there is something that was done wrong with the cert and unless you provide me more evidence I cannot really help. Can you show me that the cert is in the keystore and that this keystore is used by the Java executable that you use to run SonarQube ?