SonarCloud* version 3 does not work in Azure DevOps Pipelines (YAML)

We just migrated from SonarCLoud* version 2 to version 3. in Azure Devops (Yaml pipelines)

The task in the azure pipeline:

2024-10-22T14:17:03.7357424Z ##[error]ERROR: Error during SonarScanner execution
2024-10-22T14:17:03.7358204Z ERROR: Error during SonarScanner execution
2024-10-22T14:17:03.7359430Z ##[error]java.lang.IllegalStateException: Error when resolving baseDir
at org.sonarsource.scanner.cli.Conf.loadModuleConfigFile(Conf.java:180)
at org.sonarsource.scanner.cli.Conf.loadModulesProperties(Conf.java:152)
at org.sonarsource.scanner.cli.Conf.loadProjectProperties(Conf.java:126)
2024-10-22T14:17:03.7360221Z java.lang.IllegalStateException: Error when resolving baseDir
2024-10-22T14:17:03.7360547Z at org.sonarsource.scanner.cli.Conf.loadModuleConfigFile(Conf.java:180)
2024-10-22T14:17:03.7360877Z at org.sonarsource.scanner.cli.Conf.loadModulesProperties(Conf.java:152)
2024-10-22T14:17:03.7361206Z at org.sonarsource.scanner.cli.Conf.loadProjectProperties(Conf.java:126)
2024-10-22T14:17:03.7362188Z ##[error]at org.sonarsource.scanner.cli.Conf.properties(Conf.java:60)
at org.sonarsource.scanner.cli.Main.execute(Main.java:70)
at org.sonarsource.scanner.cli.Main.main(Main.java:62)
2024-10-22T14:17:03.7362861Z at org.sonarsource.scanner.cli.Conf.properties(Conf.java:60)
2024-10-22T14:17:03.7364939Z at org.sonarsource.scanner.cli.Main.execute(Main.java:70)
2024-10-22T14:17:03.7365229Z at org.sonarsource.scanner.cli.Main.main(Main.java:62)
2024-10-22T14:17:03.7366909Z ##[error]Caused by: java.nio.file.NoSuchFileException: D:\a\1\a1s
at java.base/sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
at java.base/sun.nio.fs.WindowsFileSystemProvider.isSameFile(Unknown Source)
at java.base/java.nio.file.Files.isSameFile(Unknown Source)
at org.sonarsource.scanner.cli.Conf.loadModuleConfigFile(Conf.java:176)

Let me know how to solve this problem

Regards,
Bart

Hi there, @BartHuls

Would you mind sharing your (redacted) pipeline here, so we know how you use the tasks?

And, if possible, also share the full (also redacted if need be) log of the failing task

Denis

Hi Dennis,

It’s a Yaml pipeline…

trigger: none

variables:
  - name: BuildConfiguration
    value: 'Release'

stages:
  - stage: Quality
    displayName: 'Quality Gate'

    jobs:
      - job: 'QualityJob'

        pool:
          name: Azure Pipelines
          vmImage: 'windows-latest'
            
        steps:
        - task: DotNetCoreCLI@2
          displayName: Restore
          inputs:
            command: restore
            projects: 'xxxx.sln'
            feedsToUse: config
            nugetConfigPath: nuget.config
        
        - task: SonarSource.sonarcloud.14d9cde6-c1da-4d55-aa01-2965cd301255.SonarCloudPrepare@3
          displayName: 'Prepare analysis on SonarCloud'
          inputs:
            SonarCloud: SonarCloud
            organization: organization
            projectKey: 'projectKey'
            projectName: 'projectKey'
            extraProperties: |
              sonar.cs.opencover.reportsPaths=$(Agent.TempDirectory)/TestResults/**/coverage.opencover.xml
              sonar.projectBaseDir=$(System.DefaultWorkingDirectory)

        - task: DotNetCoreCLI@2
          displayName: 'Build All csproj'
          inputs:
            command: build
            projects: |
                **/*.csproj
                !utils/**/*.csproj
                !**/WebApp.csproj
            arguments: '--configuration $(BuildConfiguration)'

        - task: DotNetCoreCLI@2
          displayName: 'Unit tests'
          inputs:
            command: test
            projects: '**/UnitTests.csproj'
            publishTestResults: false
            arguments: '--no-build --logger trx --results-directory $(Agent.TempDirectory)/TestResults/Unit --configuration $(BuildConfiguration) --collect:"XPlat Code Coverage;Format=opencover" --verbosity=detailed'
            workingDirectory: test/          

        - task: PublishTestResults@2
          displayName: 'Publish Test Results *.trx'
          inputs:
            testResultsFormat: VSTest
            testResultsFiles: '**/*.trx'
            searchFolder: '$(Agent.TempDirectory)/TestResults'
            mergeTestResults: true
          condition: succeededOrFailed()

        - task: SonarSource.sonarcloud.ce096e50-6155-4de8-8800-4221aaeed4a1.SonarCloudAnalyze@3
          displayName: 'Run Code Analysis'
          condition: succeeded()

        - task: SonarSource.sonarcloud.38b27399-a642-40af-bb7d-9971f69712e8.SonarCloudPublish@3
          displayName: 'Publish Quality Gate Result'
          condition: succeeded()

Thanks, @BartHuls

Our engineers are looking at the issue.
We’ll come back to this thread when we know more.

Denis

btw…

2024-10-23T07:58:45.0402383Z ##[section]Starting: Run Code Analysis
2024-10-23T07:58:45.0407448Z ==============================================================================
2024-10-23T07:58:45.0407611Z Task         : Run Code Analysis
2024-10-23T07:58:45.0407702Z Description  : Run scanner and upload the results to the SonarCloud server.
2024-10-23T07:58:45.0407825Z Version      : 3.0.1
2024-10-23T07:58:45.0407912Z Author       : sonarsource
2024-10-23T07:58:45.0408030Z Help         : This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.

[More Information](https://docs.sonarcloud.io/advanced-setup/ci-based-analysis/sonarcloud-extension-for-azure-devops/)
2024-10-23T07:58:45.0408314Z ==============================================================================
2024-10-23T07:58:45.3375291Z [command]D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\3.0.1\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe end
2024-10-23T07:58:45.4015582Z SonarScanner for MSBuild 9.0
2024-10-23T07:58:45.4016512Z Using the .NET Framework version of the Scanner for MSBuild
2024-10-23T07:58:45.4457240Z Post-processing started.
2024-10-23T07:58:47.1412280Z Calling the TFS Processor executable...
2024-10-23T07:58:47.2947067Z Fetching code coverage report information from TFS...
2024-10-23T07:58:47.2964901Z Attempting to locate a test results (.trx) file...
2024-10-23T07:58:47.3743409Z Looking for TRX files in: D:\a\1\TestResults
2024-10-23T07:58:47.3749146Z No test results files found
2024-10-23T07:58:47.4555131Z Did not find any binary coverage files in the expected location.
2024-10-23T07:58:47.4570633Z Falling back on locating coverage files in the agent temp directory.
2024-10-23T07:58:47.4574436Z Searching for coverage files in D:\a\_temp
2024-10-23T07:58:47.4579969Z No coverage files found in the agent temp directory.
2024-10-23T07:58:47.4580543Z Coverage report conversion completed successfully.
2024-10-23T07:58:47.4660429Z The TFS Processor has finished
2024-10-23T07:58:47.4717273Z Calling the SonarScanner CLI...
2024-10-23T07:58:47.6476065Z INFO: Scanner configuration file: D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\3.0.1\classic-sonar-scanner-msbuild\sonar-scanner-5.0.1.3006\bin\..\conf\sonar-scanner.properties
2024-10-23T07:58:47.6499555Z INFO: Project root configuration file: D:\a\1\.sonarqube\out\sonar-project.properties
2024-10-23T07:58:47.6956348Z INFO: ------------------------------------------------------------------------
2024-10-23T07:58:47.6957731Z INFO: EXECUTION FAILURE
2024-10-23T07:58:47.6958746Z INFO: ------------------------------------------------------------------------
2024-10-23T07:58:47.6964942Z INFO: Total time: 0.062s
2024-10-23T07:58:47.7239230Z INFO: Final Memory: 0M/8M
2024-10-23T07:58:47.7240917Z INFO: ------------------------------------------------------------------------
2024-10-23T07:58:47.7258744Z ##[error]ERROR: Error during SonarScanner execution
2024-10-23T07:58:47.7259567Z ERROR: Error during SonarScanner execution
2024-10-23T07:58:47.7260902Z ##[error]java.lang.IllegalStateException: Error when resolving baseDir
	at org.sonarsource.scanner.cli.Conf.loadModuleConfigFile(Conf.java:180)
	at org.sonarsource.scanner.cli.Conf.loadModulesProperties(Conf.java:152)
	at org.sonarsource.scanner.cli.Conf.loadProjectProperties(Conf.java:126)
2024-10-23T07:58:47.7261928Z java.lang.IllegalStateException: Error when resolving baseDir
2024-10-23T07:58:47.7262228Z 	at org.sonarsource.scanner.cli.Conf.loadModuleConfigFile(Conf.java:180)
2024-10-23T07:58:47.7262557Z 	at org.sonarsource.scanner.cli.Conf.loadModulesProperties(Conf.java:152)
2024-10-23T07:58:47.7262885Z 	at org.sonarsource.scanner.cli.Conf.loadProjectProperties(Conf.java:126)
2024-10-23T07:58:47.7263747Z ##[error]at org.sonarsource.scanner.cli.Conf.properties(Conf.java:60)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:70)
2024-10-23T07:58:47.7264350Z 	at org.sonarsource.scanner.cli.Conf.properties(Conf.java:60)
2024-10-23T07:58:47.7266240Z 	at org.sonarsource.scanner.cli.Main.execute(Main.java:70)
2024-10-23T07:58:47.7266994Z ##[error]at org.sonarsource.scanner.cli.Main.main(Main.java:62)
2024-10-23T07:58:47.7267527Z 	at org.sonarsource.scanner.cli.Main.main(Main.java:62)
2024-10-23T07:58:47.7268169Z ##[error]Caused by: java.nio.file.NoSuchFileException: D:\a\1\a1s
2024-10-23T07:58:47.7268646Z Caused by: java.nio.file.NoSuchFileException: D:\a\1\a1s
2024-10-23T07:58:47.7269832Z ##[error]at java.base/sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
	at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
	at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
	at java.base/sun.nio.fs.WindowsFileSystemProvider.isSameFile(Unknown Source)
2024-10-23T07:58:47.7270611Z 	at java.base/sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
2024-10-23T07:58:47.7270911Z 	at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
2024-10-23T07:58:47.7271209Z 	at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
2024-10-23T07:58:47.7271508Z 	at java.base/sun.nio.fs.WindowsFileSystemProvider.isSameFile(Unknown Source)
2024-10-23T07:58:47.7272337Z ##[error]at java.base/java.nio.file.Files.isSameFile(Unknown Source)
	at org.sonarsource.scanner.cli.Conf.loadModuleConfigFile(Conf.java:176)
2024-10-23T07:58:47.7272940Z 	at java.base/java.nio.file.Files.isSameFile(Unknown Source)
2024-10-23T07:58:47.7273262Z 	at org.sonarsource.scanner.cli.Conf.loadModuleConfigFile(Conf.java:176)
2024-10-23T07:58:47.7273833Z ##[error]... 5 more
2024-10-23T07:58:47.7274232Z 	... 5 more
2024-10-23T07:58:47.7274702Z ##[error]ERROR:
2024-10-23T07:58:47.7275101Z ERROR: 
2024-10-23T07:58:47.7501300Z ##[error]The SonarScanner did not complete successfully
2024-10-23T07:58:47.7506434Z The SonarScanner did not complete successfully
2024-10-23T07:58:47.7550233Z ##[error]07:58:47.732  Post-processing failed. Exit code: 1
2024-10-23T07:58:47.7553220Z 07:58:47.732  Post-processing failed. Exit code: 1
2024-10-23T07:58:47.7593688Z ##[warning]Can't find loc string for key: LIB_ProcessExitCode
2024-10-23T07:58:47.7605396Z ##[error][ERROR] SonarCloud: Error while executing task Analyze: LIB_ProcessExitCode D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\3.0.1\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe 1
2024-10-23T07:58:47.7606822Z ##[error]LIB_ProcessExitCode D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\3.0.1\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe 1
2024-10-23T07:58:47.7687103Z ##[section]Finishing: Run Code Analysis