SonarQube Extension for Azure DevOps does not delete SonarQube directories on prepare step

  • SonarQube Version: 8.9.9 Enterprise Edition
  • SonarQube Azure DevOps Extension Version: 5.4.0
  • SonarScanner for MSBuild Version: 5.5.3
  • Problem: SonarQube Prepare step (Version 5) is not deleting any previous SonarQube directories in pipeline directory
  • Current workaround: Having to delete SonarQube directory in pipeline (for example “D:\_work\1\.sonarqube”) before SonarQube prepare step

Output of prepare step:

SonarScanner for MSBuild 5.5.3
Using the .NET Framework version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories...
12:34:18.797 Updating build integration targets...
##[error]12:34:18.797 Failed to create an empty directory 'D:\\_work\\1\\.sonarqube\out'. Please check that there are no open or read-only files in the directory and that you have the necessary read/write permissions.
Detailed error message: Could not find a part of the path "D__work_1_s_Product_ObstructedString.ucfg".
12:34:18.797 Failed to create an empty directory 'D:\_work\1\.sonarqube\out'. Please check that there are no open or read-only files in the directory and that you have the necessary read/write permissions.
Detailed error message: Could not find a part of the path "D__work_1_s_Product_ObstructedString.ucfg"
##[error]12:34:18.797 Pre-processing failed. Exit code: 1
12:34:18.797 Pre-processing failed. Exit code: 1
##[error]The process 'D:\\_work\\_tasks\\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\\5.4.0\\classic-sonar-scanner-msbuild\\SonarScanner.MSBuild.exe' failed with exit code 1

We only have this problem since activating C/C++ analyzing with SonarQube Enterprise Edition.

Hi @echalone,

Could you share the verbose logs for the prepare step please/

In Azure DevOps you would add sonar.verbose=true to your pipeline e.g.

- task: SonarCloudPrepare@1
    inputs:
      SonarCloud: 'sonarcloud'
      organization: 'foo'
      scannerMode: 'MSBuild'
      projectKey: 'foo_sonar-scanning-someconsoleapp'
      projectName: 'sonar-scanning-someconsoleapp'
      extraProperties: |
        sonar.verbose=true

Log follows… we have more than one C/C++ project that’s getting analyzed, as context. The directories aren’t locked by any process and I can delete them without problems via a powershell buildstep just prior, so they are definitely not locked beforehand.

##[section]Starting: Prepare the SonarQube analysis
==============================================================================
Task         : Prepare Analysis Configuration
Description  : Prepare SonarQube analysis configuration
Version      : 5.4.0
Author       : sonarsource
Help         : Version: 5.4.0. [More Information](http://redirect.sonarsource.com/doc/install-configure-scanner-tfs-ts.html)
==============================================================================
[command]D:\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.4.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe begin /k:MyProject
SonarScanner for MSBuild 5.5.3
Using the .NET Framework version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories...
10:27:17.33  10:27:17.33  Loading analysis properties from D:\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.4.0\classic-sonar-scanner-msbuild\SonarQube.Analysis.xml
10:27:17.33  10:27:17.33  sonar.verbose=true was specified - setting the log verbosity to 'Debug'
10:27:17.33  Updating build integration targets...
10:27:17.345  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\Build\AppData\Local\Microsoft\MSBuild\4.0\Microsoft.Common.targets\ImportBefore
10:27:17.345  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\Build\AppData\Local\Microsoft\MSBuild\10.0\Microsoft.Common.targets\ImportBefore
10:27:17.345  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\Build\AppData\Local\Microsoft\MSBuild\11.0\Microsoft.Common.targets\ImportBefore
10:27:17.345  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\Build\AppData\Local\Microsoft\MSBuild\12.0\Microsoft.Common.targets\ImportBefore
10:27:17.345  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\Build\AppData\Local\Microsoft\MSBuild\14.0\Microsoft.Common.targets\ImportBefore
10:27:17.345  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\Build\AppData\Local\Microsoft\MSBuild\15.0\Microsoft.Common.targets\ImportBefore
10:27:17.345  The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\Build\AppData\Local\Microsoft\MSBuild\Current\Microsoft.Common.targets\ImportBefore
10:27:17.361  Installed SonarQube.Integration.targets to D:\_work\1\.sonarqube\bin\targets
10:27:17.361  Creating config and output folders...
10:27:17.361  Creating directory: D:\_work\1\.sonarqube\conf
10:27:17.361  Removing the existing directory: D:\_work\1\.sonarqube\out
##[error]10:27:17.361  Failed to create an empty directory 'D:\_work\1\.sonarqube\out'. Please check that there are no open or read-only files in the directory and that you have the necessary read/write permissions.
  Detailed error message: Could not find a part of the path "D__work_1_s_Product_MyProject_wwwroot_lib_jquery_validation_unobtrusive_jquery_validate_unobtrusive_js_288_26_FE_3751_ada_min_max_min_min_max.ucfg"
10:27:17.361  Failed to create an empty directory 'D:\_work\1\.sonarqube\out'. Please check that there are no open or read-only files in the directory and that you have the necessary read/write permissions.
  Detailed error message: Could not find a part of the path "D__work_1_s_Product_MyProject_wwwroot_lib_jquery_validation_unobtrusive_jquery_validate_unobtrusive_js_288_26_FE_3751_ada_min_max_min_min_max.ucfg"
##[error]10:27:17.361  Pre-processing failed. Exit code: 1
10:27:17.361  Pre-processing failed. Exit code: 1
##[error]The process 'D:\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.4.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1
##[section]Finishing: Prepare the SonarQube analysis