Deploy pipeline without using scanner-mode MsBuild

I am implementing a pipeline to run sonnar-scaner to a .NET project. I already have a service connection in azure where I have my instance for sonar.

I don’t want to use MsBuild in scanner-mode, can I use CLI? And what would be the process to send the token and to install dotnet? What else should I consider if I don’t want to use the MsBuild scanner mode. thank you

stages:
  - stage: stage_environment
    pool: ${{ variables.agent }}
    displayName  resource
    jobs:
    - job: job_build
      displayName: Build Process
      container: devops  
      steps:
      - checkout: self
        fetchDepth: 1
      - task: SonarQubePrepare@4
      inputs:
        SonarQube: 'azure-sonar'
        scannerMode: 'CLI'
        projectKey: '${{ parameters.project_name }}'
        projectName: '${{ parameters.project_name }}'

You must use the .NET scanner to analyze .NET code – you cannot use the Scanner CLI.

Hello ,thanks for your answer, I already managed to deploy the pipeline and if it runs successfully but it is not analyzing the .cs files that are the most important, what can I do?

this is my pipeline

name: $(Build.DefinitionName)_${{ replace(replace(variables['Build.SourceBranch'],'refs/heads/',''),'/','-')}}_$(date:yyyyMMdd)$(rev:.r)
    
variables:
- group: 'mygroup'
- name: agent
  value: devops
    
trigger: none
    
resources:
  containers:
  - container: devops
    image: myimage

stages:
  - stage: stage_environment
    pool: ${{ variables.agent }}
    displayName: Create environment
    jobs:
    - job: job_build
      displayName: Build Process
      container: devops
      steps:
      - checkout: self
        fetchDepth: 1

      - task: SonarQubePrepare@5.15.0
        inputs:
          SonarQube: 'azure-sonar'
          scannerMode: 'CLI'
          configMode: 'manual'
          cliProjectKey: 'prynet'
          cliProjectName: 'prynet'
          cliSources: '$(Build.SourcesDirectory)/config/'  # root of the project


      - task: UseDotNet@2
        inputs:
          command: 'build'
          
      - script: java -version
      - script: dotnet nuget --version
      
      - task: SonarQubeAnalyze@5.15.0

      - task: SonarQubePublish@5
        inputs:
          pollingTimeoutSec: '300'


result :


2023-08-17T19:05:38.1268285Z ##[section]Starting: SonarQubeAnalyze
2023-08-17T19:05:38.1272203Z ==============================================================================
2023-08-17T19:05:38.1272324Z Task         : Run Code Analysis
2023-08-17T19:05:38.1272403Z Description  : Run scanner and upload the results to the SonarQube server.
2023-08-17T19:05:38.1272497Z Version      : 5.15.0
2023-08-17T19:05:38.1272554Z Author       : sonarsource
2023-08-17T19:05:38.1272614Z Help         : Version: 5.15.0. This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.

[More Information](http://redirect.sonarsource.com/doc/install-configure-scanner-tfs-ts.html)
2023-08-17T19:05:38.1272848Z ==============================================================================
2023-08-17T19:05:38.4751876Z [command]/__w/_tasks/SonarQubeAnalyze_9589-4b15-8491-8164aeb38055/5.15.0/sonar-scanner/bin/sonar-scanner
2023-08-17T19:05:38.5614358Z INFO: Scanner configuration file: /__w/_tasks/SonarQubeAnalyze_9589-4b15-8491-8164aeb38055/5.15.0/sonar-scanner/conf/sonar-scanner.properties
2023-08-17T19:05:38.5615493Z INFO: Project root configuration file: NONE
2023-08-17T19:05:38.5822037Z INFO: SonarScanner 4.8.0.2856
2023-08-17T19:05:38.5822688Z INFO: Java 11.0.20 Ubuntu (64-bit)
2023-08-17T19:05:38.5823006Z INFO: Linux xxxxxxxxxxx amd64
2023-08-17T19:05:38.8251791Z INFO: User cache: /home/ec2-xxxxxxxxx/.sonar/cache
2023-08-17T19:05:39.1949427Z INFO: Analyzing on SonarQube server 6.7.5
2023-08-17T19:05:39.1950442Z INFO: Default locale: "en_US", source code encoding: "US-ASCII" (analysis is platform dependent)
2023-08-17T19:05:39.3827293Z INFO: Publish mode
2023-08-17T19:05:39.4884620Z INFO: Load global settings
2023-08-17T19:05:39.5407085Z INFO: Load global settings (done) | time=53ms
2023-08-17T19:05:39.5482441Z INFO: Server id: E7CCD9D6-AWUl_N6sMUMELsCFNm8K
2023-08-17T19:05:39.5548787Z INFO: User cache: /home/xxxxxxx/.sonar/cache
2023-08-17T19:05:39.7306581Z INFO: Load plugins index
2023-08-17T19:05:39.7661803Z INFO: Load plugins index (done) | time=35ms
2023-08-17T19:05:39.7670130Z INFO: Download sonar-flex-plugin-2.3.jar
2023-08-17T19:05:39.7947177Z INFO: Download sonar-scm-git-plugin-1.8.0.1574.jar
2023-08-17T19:05:39.8242032Z INFO: Download sonar-jacoco-plugin-1.0.1.143.jar
2023-08-17T19:05:39.8273144Z INFO: Download sonar-csharp-plugin-6.5.0.3766.jar
2023-08-17T19:05:39.8546605Z INFO: Download sonar-javascript-plugin-5.1.1.7506.jar
2023-08-17T19:05:39.9264427Z INFO: Download sonar-java-plugin-5.13.0.18197.jar
2023-08-17T19:05:40.0086588Z INFO: Download sonar-php-plugin-2.11.0.2485.jar
2023-08-17T19:05:40.0404281Z INFO: Download sonar-python-plugin-1.8.0.1496.jar
2023-08-17T19:05:40.0818679Z INFO: Download sonar-typescript-plugin-1.9.0.3766.jar
2023-08-17T19:05:40.1058981Z INFO: Download sonar-xml-plugin-2.0.1.2020.jar
2023-08-17T19:05:40.1303159Z INFO: Download sonar-scm-svn-plugin-1.8.0.1168.jar
2023-08-17T19:05:40.5513647Z INFO: Process project properties
2023-08-17T19:05:40.5738080Z INFO: Load project repositories
2023-08-17T19:05:40.6339122Z INFO: Load project repositories (done) | time=60ms
2023-08-17T19:05:40.7124410Z INFO: Load quality profiles
2023-08-17T19:05:40.7473015Z INFO: Load quality profiles (done) | time=35ms
2023-08-17T19:05:40.7541965Z INFO: Load active rules
2023-08-17T19:05:41.0864730Z INFO: Load active rules (done) | time=332ms
2023-08-17T19:05:41.0880059Z INFO: Load metrics repository
2023-08-17T19:05:41.1135009Z INFO: Load metrics repository (done) | time=25ms
2023-08-17T19:05:41.1347465Z INFO: Project key: prynet
2023-08-17T19:05:41.1353687Z INFO: -------------  Scan prynet
2023-08-17T19:05:41.2324142Z INFO: Load server rules
2023-08-17T19:05:41.2675314Z INFO: Load server rules (done) | time=35ms
2023-08-17T19:05:41.3247704Z INFO: Base dir: /__w/165/s
2023-08-17T19:05:41.3248472Z INFO: Working dir: /__w/165/s/.scannerwork
2023-08-17T19:05:41.3255075Z INFO: Source paths: config
2023-08-17T19:05:41.3255716Z INFO: Source encoding: US-ASCII, default locale: en_US
2023-08-17T19:05:41.3628044Z INFO: Index files
2023-08-17T19:05:41.4280317Z INFO: 158 files indexed
2023-08-17T19:05:41.4288337Z INFO: Quality profile for cs: Sonar way
2023-08-17T19:05:41.4288721Z INFO: Quality profile for xml: Sonar way
2023-08-17T19:05:41.4288994Z INFO: Excluded sources for coverage: 
2023-08-17T19:05:41.4289265Z INFO:   **/domain/**/*
2023-08-17T19:05:41.4289524Z INFO:   **/distribution/**/*
2023-08-17T19:05:41.9358090Z WARNING: An illegal reflective access operation has occurred
2023-08-17T19:05:41.9359856Z WARNING: Illegal reflective access by net.sf.cglib.core.ReflectUtils$1 (file:/home/ec2-user_azpcontainer/.sonar/cache/5xxeccc325307/sonar-javascript-plugin-5.1.1.7506.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
2023-08-17T19:05:41.9360631Z WARNING: Please consider reporting this to the maintainers of net.sf.cglib.core.ReflectUtils$1
2023-08-17T19:05:41.9361280Z WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
2023-08-17T19:05:41.9361733Z WARNING: All illegal access operations will be denied in a future release
2023-08-17T19:05:42.1872180Z INFO: Sensor C# [csharp]
2023-08-17T19:05:42.1908612Z INFO: Sensor C# [csharp] (done) | time=4ms
2023-08-17T19:05:42.1909015Z INFO: Sensor JavaXmlSensor [java]
2023-08-17T19:05:42.1936741Z INFO: 12 source files to be analyzed
2023-08-17T19:05:42.4501684Z INFO: Sensor JavaXmlSensor [java] (done) | time=259ms
2023-08-17T19:05:42.4504799Z INFO: 12/12 source files have been analyzed
2023-08-17T19:05:42.4506868Z INFO: Sensor XML Sensor [xml]
2023-08-17T19:05:42.4532017Z INFO: 13 source files to be analyzed
2023-08-17T19:05:42.7004547Z INFO: Sensor XML Sensor [xml] (done) | time=249ms
2023-08-17T19:05:42.7005086Z INFO: Sensor JaCoCo XML Report Importer [jacoco]
2023-08-17T19:05:42.7007762Z INFO: 13/13 source files have been analyzed
2023-08-17T19:05:42.7071392Z INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=6ms
2023-08-17T19:05:42.7071658Z INFO: Sensor Analyzer for "php.ini" files [php]
2023-08-17T19:05:42.7107564Z INFO: Sensor Analyzer for "php.ini" files [php] (done) | time=3ms
2023-08-17T19:05:42.7107991Z INFO: Sensor C# Tests Coverage Report Import [csharp]
2023-08-17T19:05:42.7108298Z INFO: Sensor C# Tests Coverage Report Import [csharp] (done) | time=1ms
2023-08-17T19:05:42.7108668Z INFO: Sensor [Deprecated] C# Integration Tests Coverage Report Import [csharp]
2023-08-17T19:05:42.7109010Z INFO: Sensor [Deprecated] C# Integration Tests Coverage Report Import [csharp] (done) | time=0ms
2023-08-17T19:05:42.7109339Z INFO: Sensor C# Unit Test Results Import [csharp]
2023-08-17T19:05:42.7109854Z INFO: Sensor C# Unit Test Results Import [csharp] (done) | time=0ms
2023-08-17T19:05:42.7110166Z INFO: Sensor Zero Coverage Sensor
2023-08-17T19:05:42.7360978Z INFO: Sensor Zero Coverage Sensor (done) | time=25ms
2023-08-17T19:05:42.7361495Z INFO: Sensor CPD Block Indexer
2023-08-17T19:05:42.7361807Z INFO: Sensor CPD Block Indexer (done) | time=0ms
2023-08-17T19:05:42.7516804Z INFO: SCM provider for this project is: git
2023-08-17T19:05:42.7524188Z INFO: 21 files to be analyzed
2023-08-17T19:05:42.8191109Z WARN: Shallow clone detected, no blame information will be provided. You can convert to non-shallow with 'git fetch --unshallow'.
2023-08-17T19:05:42.8215346Z INFO: 0/21 files analyzed
2023-08-17T19:05:42.8217211Z WARN: Missing blame information for the following files:
2023-08-17T19:05:42.8217732Z WARN:   * config/SI.TPMOHO.ORDERS.XLSX.TXT/ConfigurationData.cs
2023-08-17T19:05:42.8218192Z WARN:   * config/SI.TPMOHO.ORDERS.XLSX.TXT/ExcelExit.Designer.cs
2023-08-17T19:05:42.8218601Z WARN:   * config/SI.TPMOHO.ORDERS.XLSX.TXT/ExcelExit.cs
2023-08-17T19:05:42.8219010Z WARN:   * config/SI.TPMOHO.ORDERS.XLSX.TXT/ExcelExit.xsd
2023-08-17T19:05:42.8219905Z WARN:   * config/SI.TPMOHO.ORDERS.XLSX.TXT/MailManager.cs
2023-08-17T19:05:42.8220285Z WARN:   * config/SI.TPMOHO.ORDERS.XLSX.TXT/Map.cs
2023-08-17T19:05:42.8220821Z WARN:   * config/SI.TPMOHO.ORDERS.XLSX.TXT/Properties/AssemblyInfo.cs
2023-08-17T19:05:42.8221254Z WARN:   * config/SI.TPMOHO.ORDERS.XLSX.TXT/ref/Configurations.xml
2023-08-17T19:05:42.8221713Z WARN:   * config/SI.TPMOHO.ORDERS.XLSX.TXT/ref/PGAConfig.xml
2023-08-17T19:05:42.8222168Z WARN:   * config/SI.TPMOHO.ORDERS.XLSX.TXT/bin/Debug/ref/Configurations.xml
2023-08-17T19:05:42.8222642Z WARN:   * config/SI.TPMOHO.ORDERS.XLSX.TXT/bin/Debug/ref/PGAConfig.xml
2023-08-17T19:05:42.8223103Z WARN:   * config/SI.TPMOHO.ORDERS.XLSX.TXT/bin/Release/ref/Configurations.xml
2023-08-17T19:05:42.8223579Z WARN:   * config/SI.TPMOHO.ORDERS.XLSX.TXT/bin/Release/ref/PGAConfig.xml
2023-08-17T19:05:42.8224050Z WARN:   * config/TEST/Program.cs
2023-08-17T19:05:42.8224356Z WARN:   * config/TEST/Properties/AssemblyInfo.cs
2023-08-17T19:05:42.8224721Z WARN:   * config/TEST/bin/Debug/crv.IPS.SIT.ORM.xml
2023-08-17T19:05:42.8225082Z WARN:   * config/TEST/bin/Debug/ref/Configurations.xml
2023-08-17T19:05:42.8225456Z WARN:   * config/TEST/bin/Debug/ref/PGAConfig.xml
2023-08-17T19:05:42.8225819Z WARN:   * config/TEST/bin/Release/crv.IPS.SIT.ORM.xml
2023-08-17T19:05:42.8226175Z WARN:   * config/TEST/bin/Release/ref/Configurations.xml
2023-08-17T19:05:42.8226537Z WARN:   * config/TEST/bin/Release/ref/PGAConfig.xml
2023-08-17T19:05:42.8226878Z WARN: This may lead to missing/broken features in SonarQube
2023-08-17T19:05:42.8227187Z INFO: Calculating CPD for 0 files
2023-08-17T19:05:42.8244823Z INFO: CPD calculation finished
2023-08-17T19:05:42.9687769Z INFO: Analysis report generated in 137ms, dir size=346 KB
2023-08-17T19:05:43.0172080Z INFO: Analysis reports compressed in 48ms, zip size=77 KB
2023-08-17T19:05:43.0561265Z INFO: Analysis report uploaded in 39ms
2023-08-17T19:05:43.0572289Z INFO: ANALYSIS SUCCESSFUL, you can browse http://xxxxxxxxx:9000/sonar/dashboard/index/prynet
2023-08-17T19:05:43.0572900Z INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
2023-08-17T19:05:43.0573544Z INFO: More about the report processing at http://xxxxxxxxx:9000/sonar/api/ce/task?id=AYoE46dzrGTyIW5modwg
2023-08-17T19:05:43.0695434Z INFO: Task total time: 2.782 s
2023-08-17T19:05:43.1526075Z INFO: ------------------------------------------------------------------------
2023-08-17T19:05:43.1526574Z INFO: EXECUTION SUCCESS
2023-08-17T19:05:43.1526920Z INFO: ------------------------------------------------------------------------
2023-08-17T19:05:43.1527112Z INFO: Total time: 4.604s
2023-08-17T19:05:43.1945932Z INFO: Final Memory: 12M/60M
2023-08-17T19:05:43.1946679Z INFO: ------------------------------------------------------------------------
2023-08-17T19:05:43.2636294Z ##[section]Finishing: SonarQubeAnalyze


As previously mentioned;

C# code cannot be analyzed using the Scanner CLI. It will be skipped. You must use the Scanner for .NET.

And: your version is past EOL. You should upgrade to either the latest version or the current LTS at your earliest convenience. Your upgrade path is:

6.7.6 → 7.9.6 → 8.9.10 → 9.9.1 → 10.1 (last step optional)

You may find these resources helpful:

Hello, the answer is still not very clear:

  • how should I enable .NET to scan?

this is my pipeline

stages:
  - stage: stage_environment_and_resource
    pool: ${{ variables.agent }}
    displayName: Create environment and resource
    jobs:
    - job: job_build
      displayName: Build Process
      container: devops
      steps:
      - checkout: self
        fetchDepth: 1


      - task: SonarQubePrepare@5.15.0
        inputs:
          SonarQube: 'azure-sonar'
          scannerMode: 'MSBuild'
          ProjectKey: 'prynet'
          ProjectName: 'prynet'
          extraProperties: 
            sonar.cs.opencover.reportsPaths='$(Build.SourcesDirectory)/config/**/coverage.opencover.xml'
         
      - script: java -version
      - script: dotnet nuget --version
      - script: dotnet --version
      - task: UseDotNet@2
        displayName: "Install dotnet core"
        inputs:
          packageType: 'sdk'

      - task: DotNetCoreCLI@2
        displayName: "Restore dotnet packages"
        inputs:
          command: restore
          projects: "$(Build.SourcesDirectory)/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/SI.MX.EDGEWELL_MORPHO.ORDERS.XLSX.TXT.csproj"


      
      - task: SonarQubeAnalyze@5.15.0 # here is the error

      - task: SonarQubePublish@5
        inputs:
          pollingTimeoutSec: '300'

Is it necessary to indicate the url of the .csproj? Is it necessary to indicate the url of the .sln file?

so far the pipeline throws an error in the task task: SonarQubeAnalyze@5.15.0.

that is, the previous tasks have passed successfully:

      - task: SonarQubePrepare@5.15.0
        inputs:
          SonarQube: 'azure-sonar'
          scannerMode: 'MSBuild'
          ProjectKey: 'prynet'
          ProjectName: 'prynet'
          extraProperties: 
            sonar.cs.opencover.reportsPaths='$(Build.SourcesDirectory)/config/**/coverage.opencover.xml'
         
      - script: java -version
      - script: dotnet nuget --version
      - script: dotnet --version
      - task: UseDotNet@2
        displayName: "Install dotnet core"
        inputs:
          packageType: 'sdk'

      - task: DotNetCoreCLI@2
        displayName: "Restore dotnet packages"
        inputs:
          command: restore
          projects: "$(Build.SourcesDirectory)/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/SI.MX.EDGEWELL_MORPHO.ORDERS.XLSX.TXT.csproj"


This is the error:

2023-08-18T02:16:53.2103385Z ##[section]Starting: SonarQubeAnalyze
2023-08-18T02:16:53.2107104Z ==============================================================================
2023-08-18T02:16:53.2107222Z Task         : Run Code Analysis
2023-08-18T02:16:53.2107286Z Description  : Run scanner and upload the results to the SonarQube server.
2023-08-18T02:16:53.2107397Z Version      : 5.15.0
2023-08-18T02:16:53.2107454Z Author       : sonarsource
2023-08-18T02:16:53.2107514Z Help         : Version: 5.15.0. This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.

[More Information](http://redirect.sonarsource.com/doc/install-configure-scanner-tfs-ts.html)
2023-08-18T02:16:53.2107742Z ==============================================================================
2023-08-18T02:16:53.6145028Z [command]/usr/bin/dotnet /__w/_tasks/SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157/5.15.0/dotnet-sonar-scanner-msbuild/SonarScanner.MSBuild.dll end
2023-08-18T02:16:53.7026189Z SonarScanner for MSBuild 5.13
2023-08-18T02:16:53.7027507Z Using the .NET Core version of the Scanner for MSBuild
2023-08-18T02:16:53.7735487Z Post-processing started.
2023-08-18T02:16:53.8618955Z ##[error]02:16:53.854  The SonarScanner for MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
Possible causes:
  1. The project has not been built - the project must be built in between the begin and end steps
  2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0.25420.1 and higher are supported.
  3. The begin, build and end steps have not all been launched from the same folder
  4. None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)
2023-08-18T02:16:53.8641458Z 02:16:53.854  The SonarScanner for MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
2023-08-18T02:16:53.8641732Z Possible causes:
2023-08-18T02:16:53.8642163Z   1. The project has not been built - the project must be built in between the begin and end steps
2023-08-18T02:16:53.8642434Z   2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0.25420.1 and higher are supported.
2023-08-18T02:16:53.8642690Z   3. The begin, build and end steps have not all been launched from the same folder
2023-08-18T02:16:53.8642922Z   4. None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)
2023-08-18T02:16:53.8643265Z 02:16:53.855  Generation of the sonar-properties file failed. Unable to complete the analysis.
2023-08-18T02:16:53.8644006Z ##[error]02:16:53.859  Post-processing failed. Exit code: 1
2023-08-18T02:16:53.8644507Z 02:16:53.859  Post-processing failed. Exit code: 1
2023-08-18T02:16:53.8692067Z ##[error]The process '/usr/bin/dotnet' failed with exit code 1
2023-08-18T02:16:53.8917273Z ##[section]Finishing: SonarQubeAnalyze

It looks like you run a dotnet restore, but never a dotnet build (or similar build command), which is required.

I added the build like this

      - task: DotNetCoreCLI@2
        displayName: "Build"
        inputs:
          command: 'build'
          projects: "$(Build.SourcesDirectory)/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/SI.MX.EDGEWELL_MORPHO.ORDERS.XLSX.TXT.csproj"
          arguments: '--configuration Release'

but I get this error:

2023-08-18T21:16:32.9131367Z ##[section]Starting: Build
2023-08-18T21:16:32.9138112Z ==============================================================================
2023-08-18T21:16:32.9138229Z Task         : .NET Core
2023-08-18T21:16:32.9138295Z Description  : Build, test, package, or publish a dotnet application, or run a custom dotnet command
2023-08-18T21:16:32.9138406Z Version      : 2.221.0
2023-08-18T21:16:32.9138462Z Author       : Microsoft Corporation
2023-08-18T21:16:32.9138539Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
2023-08-18T21:16:32.9138649Z ==============================================================================
2023-08-18T21:16:33.5050464Z Info: .NET Core SDK/runtime 2.2 and 3.0 are now End of Life(EOL) and have been removed from all hosted agents. If you're using these SDK/runtimes on hosted agents, kindly upgrade to newer versions which are not EOL, or else use UseDotNet task to install the required version.
2023-08-18T21:16:33.5095113Z [command]/usr/bin/dotnet build /__w/7/s/config/SI.SLN.MX.EDGEWELL_MORPHO.ORDERS.sln -dl:CentralLogger,"/__w/_tasks/DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b/2.221.0/dotnet-build-helpers/Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"*ForwardingLogger,"/__w/_tasks/DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b/2.221.0/dotnet-build-helpers/Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" --configuration Release
2023-08-18T21:16:33.6517249Z MSBuild version 17.3.2+561848881 for .NET
2023-08-18T21:16:33.7827080Z ##[error]config/SI.SLN.MX.EDGEWELL_MORPHO.ORDERS.sln(0,0): Error MSB5014: File format version is not recognized.  MSBuild can only read solution files between versions 7.0 and 12.0, inclusive.
2023-08-18T21:16:33.7837142Z /__w/7/s/config/SI.SLN.MX.EDGEWELL_MORPHO.ORDERS.sln : Solution file error MSB5014: File format version is not recognized.  MSBuild can only read solution files between versions 7.0 and 12.0, inclusive.
2023-08-18T21:16:33.7837370Z 
2023-08-18T21:16:33.7837482Z Build FAILED.
2023-08-18T21:16:33.7837571Z 
2023-08-18T21:16:33.7837818Z /__w/7/s/config/SI.SLN.MX.EDGEWELL_MORPHO.ORDERS.sln : Solution file error MSB5014: File format version is not recognized.  MSBuild can only read solution files between versions 7.0 and 12.0, inclusive.
2023-08-18T21:16:33.7838085Z     0 Warning(s)
2023-08-18T21:16:33.7838225Z     1 Error(s)
2023-08-18T21:16:33.7838280Z 
2023-08-18T21:16:33.7838419Z Time Elapsed 00:00:00.02
2023-08-18T21:16:33.8060521Z ##[error]Error: The process '/usr/bin/dotnet' failed with exit code 1
2023-08-18T21:16:33.8061931Z ##[warning].NET 5 has some compatibility issues with older Nuget versions(<=5.7), so if you are using an older Nuget version(and not dotnet cli) to restore, then the dotnet cli commands (e.g. dotnet build) which rely on such restored packages might fail. To mitigate such error, you can either: (1) - Use dotnet cli to restore, (2) - Use Nuget version 5.8 to restore, (3) - Use global.json using an older sdk version(<=3) to build
2023-08-18T21:16:33.8078182Z Info: Azure Pipelines hosted agents have been updated and now contain .Net 5.x SDK/Runtime along with the older .Net Core version which are currently lts. Unless you have locked down a SDK version for your project(s), 5.x SDK might be picked up which might have breaking behavior as compared to previous versions. You can learn more about the breaking changes here: https://docs.microsoft.com/en-us/dotnet/core/tools/ and https://docs.microsoft.com/en-us/dotnet/core/compatibility/ . To learn about more such changes and troubleshoot, refer here: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting
2023-08-18T21:16:33.8079851Z ##[error]Dotnet command failed with non-zero exit code on the following projects : [ '/__w/7/s/config/SI.SLN.MX.EDGEWELL_MORPHO.ORDERS.sln' ]
2023-08-18T21:16:33.8237457Z ##[section]Finishing: Build

Now, I added the build like this:

       -task: MSBuild@1
         inputs:
           solution: "$(Build.SourcesDirectory)/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/SI.MX.EDGEWELL_MORPHO.ORDERS.XLSX.TXT.csproj"
           msbuildVersion: '16.0'
           configuration: 'Release'
           platform: 'AnyCPU'

and it seems to work

2023-08-22T14:15:46.5646592Z ##[section]Starting: MSBuild
2023-08-22T14:15:46.5651688Z ==============================================================================
2023-08-22T14:15:46.5651817Z Task         : MSBuild
2023-08-22T14:15:46.5651877Z Description  : Build with MSBuild
2023-08-22T14:15:46.5651962Z Version      : 1.217.0
2023-08-22T14:15:46.5652019Z Author       : Microsoft Corporation
2023-08-22T14:15:46.5652086Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/msbuild
2023-08-22T14:15:46.5652193Z ==============================================================================
2023-08-22T14:15:47.0698717Z [command]/usr/bin/xbuild /__w/1/s/config/SI.SLN.MX.EDGEWELL_MORPHO.ORDERS.sln
2023-08-22T14:15:47.1251696Z 
2023-08-22T14:15:47.1253927Z >>>> xbuild tool is deprecated and will be removed in future updates, use msbuild instead <<<<
2023-08-22T14:15:47.1254132Z 
2023-08-22T14:15:47.1254416Z XBuild Engine Version 14.0
2023-08-22T14:15:47.1254662Z Mono, Version 6.8.0.105
2023-08-22T14:15:47.1255133Z Copyright (C) 2005-2013 Various Mono authors
2023-08-22T14:15:47.2034119Z 
2023-08-22T14:15:47.2039018Z Build started 08/22/2023 14:15:47.
2023-08-22T14:15:47.2039413Z __________________________________________________
2023-08-22T14:15:47.3894367Z /__w/1/s/config/SI.SLN.MX.EDGEWELL_MORPHO.ORDERS.sln:  warning : Don't know how to handle GlobalSection ExtensibilityGlobals, Ignoring.
2023-08-22T14:15:47.4491021Z Project "/__w/1/s/config/SI.SLN.MX.EDGEWELL_MORPHO.ORDERS.sln" (default target(s)):
2023-08-22T14:15:47.4508255Z 	Target ValidateSolutionConfiguration:
2023-08-22T14:15:47.4508834Z 		Building solution configuration "Debug|Any CPU".
2023-08-22T14:15:47.4981698Z 	Target Build:
2023-08-22T14:15:47.4982151Z 		Project "/__w/1/s/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/SI.MX.EDGEWELL_MORPHO.ORDERS.XLSX.TXT.csproj" (default target(s)):
2023-08-22T14:15:47.4982381Z 			Target PrepareForBuild:
2023-08-22T14:15:47.4982559Z 				Configuration: Debug Platform: AnyCPU
2023-08-22T14:15:47.6720669Z 			Target CopyNonResxEmbeddedResources:
2023-08-22T14:15:47.6722227Z 				Copying file from '/__w/1/s/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/Referencias/Configurations.xml' to '/__w/1/s/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/obj/Debug/SI.MX.EDGEWELL_MORPHO.ORDERS.XLSX.TXT.Referencias.Configurations.xml'
2023-08-22T14:15:47.6727044Z 				Copying file from '/__w/1/s/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/Referencias/MailLayout.html' to '/__w/1/s/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/obj/Debug/SI.MX.EDGEWELL_MORPHO.ORDERS.XLSX.TXT.Referencias.MailLayout.html'
2023-08-22T14:15:47.6738188Z 			Target GenerateSatelliteAssemblies:
2023-08-22T14:15:47.6738636Z 			No input files were specified for target GenerateSatelliteAssemblies, skipping.
2023-08-22T14:15:47.6868701Z 			Target CoreCompile:
2023-08-22T14:15:47.6872657Z 				Tool /usr/lib/mono/4.5/mcs.exe execution started with arguments: /noconfig /debug:full /debug:portable /optimize- /out:obj/Debug/SI.MX.EDGEWELL_MORPHO.ORDERS.XLSX.TXT.dll /resource:obj/Debug/SI.MX.EDGEWELL_MORPHO.ORDERS.XLSX.TXT.Referencias.Configurations.xml /resource:obj/Debug/SI.MX.EDGEWELL_MORPHO.ORDERS.XLSX.TXT.Referencias.MailLayout.html ConfigurationData.cs ExcelExit.cs ExcelExit.Designer.cs MailManager.cs Map.cs Properties/AssemblyInfo.cs obj/Debug/.NETFramework,Version=v4.6.1.AssemblyAttribute.cs /target:library /define:"DEBUG;TRACE" /nostdlib /reference:/__w/1/s/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/bin/Debug/Carvajal.IPS.Functions.dll /reference:/__w/1/s/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/bin/Debug/Carvajal.IPS.SIT.Common.dll /reference:/__w/1/s/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/bin/Debug/Carvajal.IPS.SIT.ORM.dll /reference:/__w/1/s/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/bin/Debug/Carvajal.IPS.SIT.StartMaps.dll /reference:/__w/1/s/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/bin/Debug/Carvajal.IPS.SIT.Structures.dll /reference:/__w/1/s/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/bin/Debug/Carvajal.SI.PGA.Core.dll /reference:/__w/1/s/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/bin/Debug/Carvajal.SI.PGA.Formats.dll /reference:/__w/1/s/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/bin/Debug/Carvajal.SI.PGA.Interop.dll /reference:/__w/1/s/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/bin/Debug/Excel.dll /reference:/usr/lib/mono/4.6.1-api/ICSharpCode.SharpZipLib.dll /reference:/__w/1/s/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/bin/Debug/log4net.dll /reference:/usr/lib/mono/4.6.1-api/System.dll /reference:/usr/lib/mono/4.6.1-api/System.Xml.Linq.dll /reference:/usr/lib/mono/4.6.1-api/System.Data.DataSetExtensions.dll /reference:/usr/lib/mono/4.6.1-api/System.Data.dll /reference:/usr/lib/mono/4.6.1-api/System.Xml.dll /reference:/usr/lib/mono/4.6.1-api/System.Core.dll /reference:/usr/lib/mono/4.6.1-api//mscorlib.dll /warn:4
2023-08-22T14:15:47.9657731Z Map.cs(828,30): warning CS0168: The variable `exc' is declared but never used
2023-08-22T14:15:47.9658259Z Map.cs(944,30): warning CS0168: The variable `ex' is declared but never used
2023-08-22T14:15:47.9684147Z Map.cs(1234,21): warning CS0219: The variable `formateado' is assigned but its value is never used
2023-08-22T14:15:48.0511483Z 			Target _CopyDeployFilesToOutputDirectoryPreserveNewest:
2023-08-22T14:15:48.0512409Z 			Skipping target "_CopyDeployFilesToOutputDirectoryPreserveNewest" because its outputs are up-to-date.
2023-08-22T14:15:48.0603907Z 			Target DeployOutputFiles:
2023-08-22T14:15:48.0606227Z 				Copying file from '/__w/1/s/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/obj/Debug/SI.MX.EDGEWELL_MORPHO.ORDERS.XLSX.TXT.dll.mdb' to '/__w/1/s/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/bin/Debug/SI.MX.EDGEWELL_MORPHO.ORDERS.XLSX.TXT.dll.mdb'
2023-08-22T14:15:48.0607216Z 				Copying file from '/__w/1/s/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/obj/Debug/SI.MX.EDGEWELL_MORPHO.ORDERS.XLSX.TXT.pdb' to '/__w/1/s/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/bin/Debug/SI.MX.EDGEWELL_MORPHO.ORDERS.XLSX.TXT.pdb'
2023-08-22T14:15:48.0617177Z 				Copying file from '/__w/1/s/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/obj/Debug/SI.MX.EDGEWELL_MORPHO.ORDERS.XLSX.TXT.dll' to '/__w/1/s/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/bin/Debug/SI.MX.EDGEWELL_MORPHO.ORDERS.XLSX.TXT.dll'
2023-08-22T14:15:48.0825541Z 		Done building project "/__w/1/s/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/SI.MX.EDGEWELL_MORPHO.ORDERS.XLSX.TXT.csproj".
2023-08-22T14:15:48.0833437Z 		The project 'TEST' is disabled for solution configuration 'Debug|Any CPU'.
2023-08-22T14:15:48.0842906Z Done building project "/__w/1/s/config/SI.SLN.MX.EDGEWELL_MORPHO.ORDERS.sln".
2023-08-22T14:15:48.0843073Z 
2023-08-22T14:15:48.0855920Z Build succeeded.
2023-08-22T14:15:48.0856422Z 
2023-08-22T14:15:48.0856718Z Warnings:
2023-08-22T14:15:48.0856841Z 
2023-08-22T14:15:48.0857699Z /__w/1/s/config/SI.SLN.MX.EDGEWELL_MORPHO.ORDERS.sln:  warning : Don't know how to handle GlobalSection ExtensibilityGlobals, Ignoring.
2023-08-22T14:15:48.0857970Z 
2023-08-22T14:15:48.0858310Z /__w/1/s/config/SI.SLN.MX.EDGEWELL_MORPHO.ORDERS.sln (default targets) ->
2023-08-22T14:15:48.0858657Z (Build target) ->
2023-08-22T14:15:48.0859134Z /__w/1/s/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/SI.MX.EDGEWELL_MORPHO.ORDERS.XLSX.TXT.csproj (default targets) ->
2023-08-22T14:15:48.0859847Z /usr/lib/mono/xbuild/14.0/bin/Microsoft.CSharp.targets (CoreCompile target) ->
2023-08-22T14:15:48.0860019Z 
2023-08-22T14:15:48.0860512Z 	Map.cs(828,30): warning CS0168: The variable `exc' is declared but never used
2023-08-22T14:15:48.0861081Z 	Map.cs(944,30): warning CS0168: The variable `ex' is declared but never used
2023-08-22T14:15:48.0862063Z 	Map.cs(1234,21): warning CS0219: The variable `formateado' is assigned but its value is never used
2023-08-22T14:15:48.0862252Z 
2023-08-22T14:15:48.0862485Z 	 4 Warning(s)
2023-08-22T14:15:48.0862698Z 	 0 Error(s)
2023-08-22T14:15:48.0862809Z 
2023-08-22T14:15:48.0863089Z Time Elapsed 00:00:00.8818940
2023-08-22T14:15:48.1861579Z ##[section]Finishing: MSBuild


but in the SonarQubeAnalyze@5.15.0 task I get this error :

2023-08-22T14:15:48.1878254Z ##[section]Starting: SonarQubeAnalyze
2023-08-22T14:15:48.1882586Z ==============================================================================
2023-08-22T14:15:48.1882730Z Task         : Run Code Analysis
2023-08-22T14:15:48.1882799Z Description  : Run scanner and upload the results to the SonarQube server.
2023-08-22T14:15:48.1882902Z Version      : 5.15.0
2023-08-22T14:15:48.1882983Z Author       : sonarsource
2023-08-22T14:15:48.1883051Z Help         : Version: 5.15.0. This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.

[More Information](http://redirect.sonarsource.com/doc/install-configure-scanner-tfs-ts.html)
2023-08-22T14:15:48.1883278Z ==============================================================================
2023-08-22T14:15:48.6708467Z [command]/usr/bin/dotnet /__w/_tasks/SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157/5.15.0/dotnet-sonar-scanner-msbuild/SonarScanner.MSBuild.dll end
2023-08-22T14:15:48.7365992Z SonarScanner for MSBuild 5.13
2023-08-22T14:15:48.7366537Z Using the .NET Core version of the Scanner for MSBuild
2023-08-22T14:15:48.8051228Z Post-processing started.
2023-08-22T14:15:48.8891435Z ##[error]14:15:48.884  The SonarScanner for MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
Possible causes:
  1. The project has not been built - the project must be built in between the begin and end steps
  2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0.25420.1 and higher are supported.
  3. The begin, build and end steps have not all been launched from the same folder
  4. None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)
2023-08-22T14:15:48.8905431Z 14:15:48.884  The SonarScanner for MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
2023-08-22T14:15:48.8905694Z Possible causes:
2023-08-22T14:15:48.8907605Z   1. The project has not been built - the project must be built in between the begin and end steps
2023-08-22T14:15:48.8907981Z   2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0.25420.1 and higher are supported.
2023-08-22T14:15:48.8908228Z   3. The begin, build and end steps have not all been launched from the same folder
2023-08-22T14:15:48.8908462Z   4. None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)
2023-08-22T14:15:48.8908849Z 14:15:48.884  Generation of the sonar-properties file failed. Unable to complete the analysis.
2023-08-22T14:15:48.8909783Z ##[error]14:15:48.889  Post-processing failed. Exit code: 1
2023-08-22T14:15:48.8910338Z 14:15:48.889  Post-processing failed. Exit code: 1
2023-08-22T14:15:48.8992033Z ##[error]The process '/usr/bin/dotnet' failed with exit code 1
2023-08-22T14:15:48.9137124Z ##[section]Finishing: SonarQubeAnalyze

Thank u

Some help @Colin

If your project is meant to be using xbuild (which appears to be a very old build tool that hasn’t been maintained in almost a decade)… I don’t think you’re going to have much luck. The Scanner for .NET has never been tested with xbuild, and it looks like its last release was even before Microsoft’s Roslyn compiler shipped, which is what our analyzers are based on.

I suggest finding out more about this project to understand why xbuild is being used and if there’s a way to build the project with modern build tools, which are more likely to work with SonarQube.

Thank u @Colin

I have updated my pipeline to use msbuild.

If I use xbuild (mono in my docker image ) it does the build , but now with msbuild I get this error, in the build task, it refers to the NET version.

    Task         : .NET Core
    Description  : Build, test, package, or publish a dotnet application, or run a custom dotnet command
    Version      : 2.221.0
    Author       : Microsoft Corporation
    Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
    ==============================================================================
    Info: .NET Core SDK/runtime 2.2 and 3.0 are now End of Life(EOL) and have been removed from all hosted agents. If you're using these SDK/runtimes on hosted agents, kindly upgrade to newer versions which are not EOL, or else use UseDotNet task to install the required version.
    /usr/bin/dotnet build /__w/1/s/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/SI.MX.EDGEWELL_MORPHO.ORDERS.XLSX.TXT.csproj -dl:CentralLogger,"/__w/_tasks/DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b/2.221.0/dotnet-build-helpers/Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"*ForwardingLogger,"/__w/_tasks/DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b/2.221.0/dotnet-build-helpers/Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"
    Microsoft (R) Build Engine version 17.0.1+b177f8fa7 for .NET
    Copyright (C) Microsoft Corporation. All rights reserved.

      Determining projects to restore...
      Nothing to do. None of the projects specified contain packages to restore.
    ##[error]/usr/lib/dotnet/sdk/6.0.121/Microsoft.Common.CurrentVersion.targets(1217,5): Error MSB3644: The reference assemblies for .NETFramework,Version=v3.5 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks
    /usr/lib/dotnet/sdk/6.0.121/Microsoft.Common.CurrentVersion.targets(1217,5): error MSB3644: The reference assemblies for .NETFramework,Version=v3.5 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [/__w/1/s/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/SI.MX.EDGEWELL_MORPHO.ORDERS.XLSX.TXT.csproj]

    Build FAILED.

    /usr/lib/dotnet/sdk/6.0.121/Microsoft.Common.CurrentVersion.targets(1217,5): error MSB3644: The reference assemblies for .NETFramework,Version=v3.5 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [/__w/1/s/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/SI.MX.EDGEWELL_MORPHO.ORDERS.XLSX.TXT.csproj]
        0 Warning(s)
        1 Error(s)

    Time Elapsed 00:00:00.74
    ##[error]Error: The process '/usr/bin/dotnet' failed with exit code 1
    ##[warning].NET 5 has some compatibility issues with older Nuget versions(<=5.7), so if you are using an older Nuget version(and not dotnet cli) to restore, then the dotnet cli commands (e.g. dotnet build) which rely on such restored packages might fail. To mitigate such error, you can either: (1) - Use dotnet cli to restore, (2) - Use Nuget version 5.8 to restore, (3) - Use global.json using an older sdk version(<=3) to build


This is the task that I am using in the pipeline

      - task: DotNetCoreCLI@2
        displayName: "Build dotnet packages"
        inputs:
          command: build
          projects: "$(Build.SourcesDirectory)/config/SI.MX.EDGWELL_MORPHO.ORDERS.XLSX.TXT/SI.MX.EDGEWELL_MORPHO.ORDERS.XLSX.TXT.csproj"
          
      - task: SonarQubeAnalyze@5

my .csproj file has the following:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>8.0.30703</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{296EB8A9-7BDF-47E2-91BD-BE47BF507C3A}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>SI.MX.EDGEWELL_MORPHO.ORDERS.XLSX.TXT</RootNamespace>
    <AssemblyName>SI.MX.EDGEWELL_MORPHO.ORDERS.XLSX.TXT</AssemblyName>
    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <SccProjectName>SAK</SccProjectName>
    <SccLocalPath>SAK</SccLocalPath>
    <SccAuxPath>SAK</SccAuxPath>
    <SccProvider>SAK</SccProvider>
  </PropertyGroup>

but the error says that a version was not found for the project.

any suggestions?

@Colin I have tried to replicate what is done in windows locally, since locally only with the .properties file and running the sonarscaner it is possible to do the correct analysis.

      - task: SonarQubePrepare@5
        inputs:
          SonarQube: 'azure-sonar'
          scannerMode: 'CLI'
          configMode: 'file'
          ProjectKey: 'prynet'
          ProjectName: 'prynet'
          configFile: "$(Build.SourcesDirectory)/sonar-project.properties"

      - task: SonarQubeAnalyze@5

      - task: SonarQubePublish@5
        inputs:
          pollingTimeoutSec: '300'

the file .properties in the root of the repo

sonar.projectKey = prynet
sonar.projectName = prynet
sonar.version = 1.0
sonar.sources = "$(Build.SourcesDirectory)"  # already try with . 

sonar.languages = cs


i get this error

    INFO: Download sonar-python-plugin-1.8.0.1496.jar
    INFO: Download sonar-typescript-plugin-1.9.0.3766.jar
    INFO: Download sonar-xml-plugin-2.0.1.2020.jar
    INFO: Download sonar-scm-svn-plugin-1.8.0.1168.jar
    INFO: Process project properties
    INFO: ------------------------------------------------------------------------
    INFO: EXECUTION FAILURE
    INFO: ------------------------------------------------------------------------
    INFO: Total time: 2.288s
    INFO: Final Memory: 7M/54M
    INFO: ------------------------------------------------------------------------
    ##[error]ERROR: Error during SonarScanner execution
    ERROR: You must define the following mandatory properties for 'Unknown': sonar.projectKey, sonar.sources
    ERROR: 
    ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
    ERROR: Error during SonarScanner execution
    ERROR: You must define the following mandatory properties for 'Unknown': sonar.projectKey, sonar.sources
    ERROR: 
    ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
    ##[error]The process '/__w/_tasks/SonarQubeAnalyze_6d01813a-9589-4b15-8491-8164aeb38055/5.15.0/sonar-scanner/bin/sonar-scanner' failed with exit code 2
    Finishing: SonarQubeAnalyze

Hey there.

I think I’m running out of help I can provide.

  • SonarQube v6.7 is an EOL version of SonarQube with no support. You need to use a recent version of SonarQube, v9.9 LTS or v10.1
  • It’s not possible to analyze .NET files with the Scanner CLI. You need to build it with MSBuild and use the Scanner for .NET.
  • Your project needs to be compiled with a “recent” version of MSBuild (as documented, 14.0 or greater), although the build can still target old framework versions

Helping you get your build working on MSBuild for this specific project is out of scope for this community. However – if you accomplish that and upgrade to a supported version of SonarQube, it should be easy to integrate SonarQube analysis.