Sonar Cloud Prep analysis, generates Sonarqube/Out .ucfg file too long

Template for a good new topic, formatted with Markdown:

  • ALM used: Azure DevOps
  • CI system used: Azure DevOps
  • Scanner MS Build
  • Languages of the repository: C#
  • Error observed (wrap logs/code around with triple quotes ``` for proper formatting)
  • Steps to reproduce
    Run SonarCloudPrepare, Sonarqube/Out folder generated by SonarCloud Azure DevOps extension
    Actual result on selfhosted build agent: C:\vsts-agent-win-x64-2.173.0_work\1.sonarqube\out\4_2_173_0__work_1_s_src_Coloplast_Direct_Web_ClientResources_epi_forms_custom_CustomFieldSelector_js_14_106_FE45_dec_lan_dom_dom_dom_dom_que_whe_Htm__Te__Wi__Wi_But_Too_dep__Va_Dia__Co__Ha_Fie_tem_res.ucfg
    Build fails; chars above limit. 255
  • Potential workaround: Reinstall Agent SW, this is only threating the symptoms, not the right solution

@mickaelcaro, could you take a look on this?

Hi @dkcdbh and welcome to the community !

Shipped Scanner for .NET, when executed on windows, doesn’t support yet more than 255 characters.

If you can’t reduce this number, my suggestion would be to run the .NET Core version of the Scanner, it should be ok.

Let me know.

Thanks.

Hi Mikael and Thank U.

Sorry my noviceness, but how do I change the scanner mode?

Best regards
Christian

If you are currently using the Azure DevOps extension for SonarCloud, then you will need to disable the related tasks (Prepare analysis configuration, Run Code Analysis) and to replace them, use commandline to execute the Scanner for .NET “by hand”. You’ll find some documentation here : https://sonarcloud.io/documentation/analysis/scan/sonarscanner-for-msbuild/

TLDR, you need to replace the Prepare analysis configuration with

dotnet SonarScanner.MSBuild.dll {arguments}

And the Run Code Analysis by

dotnet SonarScanner.MSBuild.dll end {arguments}

HTH,

Hi Mickael
I keep getting this error
S C:> dotnet C:\sonar-scanner-msbuild-5.0.4.24009-netcoreapp3.0\SonarScanner.MSBuild.dll begin /k:“SCN” /o:“digitalcustomerprogram2020” /d:sonar.login=“fa18dea8da2176bebxxxxxxxxxxxx”
SonarScanner for MSBuild 5.0.4
Using the .NET Core version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories…
13:59:25.966 Updating build integration targets…
13:59:26.484 Failed to request and parse ‘https://sonarcloud.io/projects/api/server/version’: Version string portion was too short or too long. (Parameter ‘input’)
13:59:26.492 Version string portion was too short or too long. (Parameter ‘input’)
13:59:26.495 Pre-processing failed. Exit code: 1
Any clues?

Hi @dkcdbh

What is the value of your sonar.host.url parameter ?

Thanks.

Property Name=“sonar.host.url”>https://sonarcloud.io/projects

You can put simply Property Name=“sonar.host.url”>https://sonarcloud.io/

It will be ok.