SonarQubeAnalyze@4 fails because of missing directory

  • SonarQube 9.9.1
  • Azure DevOps Services
  • Run Code Analysis 4.36.1
  • CMake 3.29.3
  • Visual Studio 16 2019

Hi,

I have the same problem as in closed topic

New CMake versions generate temporary folders that are deleted before end of build. sonar-scanner fails when it encounters such folders. Were there any compatibility fixes done to make SonarQube compatible with CMake from the box?

Current potential workarounds:

  • change file that is generated during build by build wrapper before running Run Code Analysis. This idea might work but it doesn’t look pretty.
  • Try to add --debug-trycompile for CMake calls. This is not trivial because CMake is called not just for generating main solution file but also multiple times internally during build process as custom command.
20:15:58.645 ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: The base directory of the module '2676BEBC-237C-31D7-906B-294DF5CBD9FE' does not exist: E:\Bld\A7\14\s\Build\CMakeFiles\CMakeScratch\TryCompile-p0vf86
	at org.sonarsource.scanner.cli.Conf.setModuleBaseDir(Conf.java:195)
	at org.sonarsource.scanner.cli.Conf.loadModuleConfigFile(Conf.java:174)
	at org.sonarsource.scanner.cli.Conf.loadModulesProperties(Conf.java:152)
	at org.sonarsource.scanner.cli.Conf.loadProjectProperties(Conf.java:126)
	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)
Process returned exit code 1
The SonarScanner did not complete successfully
20:15:58.723  Post-processing failed. Exit code: 1

##[error]The process 'E:\Bld\A7\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.36.1\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1

Hi,

I solved it by running the SonarQube configuration step after running CMake and before running the build process.