java.lang.IllegalStateException: The base directory of the module does not exist

The “Run Code Analysis” task in an Azure DevOps pipeline building a .NET Core project is failing with the below logs in our case -

Executing file C:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.4.0\classic-sonar-scanner-msbuild\sonar-scanner-4.6.2.2472\bin\sonar-scanner.bat
Args: -Dsonar.scanAllFiles=true -Dproject.settings=C:\a\6\.sonarqube\out\sonar-project.properties --from=ScannerMSBuild/5.5.3 --debug <sensitive data removed>
Working directory: C:\a\6
Timeout (ms):-1
Process id: 1696
06:01:15.552 INFO: Scanner configuration file: C:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.4.0\classic-sonar-scanner-msbuild\sonar-scanner-4.6.2.2472\bin\..\conf\sonar-scanner.properties
06:01:15.552 INFO: Project root configuration file: C:\a\6\.sonarqube\out\sonar-project.properties
06:01:15.630 INFO: ------------------------------------------------------------------------
06:01:15.630 INFO: EXECUTION FAILURE
06:01:15.630 INFO: ------------------------------------------------------------------------
06:01:15.646 INFO: Total time: 0.157s
06:01:15.661 INFO: Final Memory: 1M/14M
06:01:15.661 INFO: ------------------------------------------------------------------------
##[error]06:01:15.661 ERROR: Error during SonarScanner execution
06:01:15.661 ERROR: Error during SonarScanner execution
##[error]java.lang.IllegalStateException: The base directory of the module 'E5E64F9D-60D3-4AF3-8CBD-7F871CB1477D' does not exist: C:\Users\AzDevOps\AppData\Local\Temp\i31l0mwh.5aw
java.lang.IllegalStateException: The base directory of the module 'E5E64F9D-60D3-4AF3-8CBD-7F871CB1477D' does not exist: C:\Users\AzDevOps\AppData\Local\Temp\i31l0mwh.5aw
##[error]at org.sonarsource.scanner.cli.Conf.setModuleBaseDir(Conf.java:205)
at org.sonarsource.scanner.cli.Conf.loadModuleConfigFile(Conf.java:184)
at org.sonarsource.scanner.cli.Conf.setModuleBaseDir(Conf.java:205)
at org.sonarsource.scanner.cli.Conf.loadModuleConfigFile(Conf.java:184)
##[error]at org.sonarsource.scanner.cli.Conf.loadModulesProperties(Conf.java:162)
at org.sonarsource.scanner.cli.Conf.loadModulesProperties(Conf.java:162)
##[error]at org.sonarsource.scanner.cli.Conf.loadProjectProperties(Conf.java:136)
at org.sonarsource.scanner.cli.Conf.properties(Conf.java:61)
at org.sonarsource.scanner.cli.Conf.loadProjectProperties(Conf.java:136)
at org.sonarsource.scanner.cli.Conf.properties(Conf.java:61)
##[error]at org.sonarsource.scanner.cli.Main.execute(Main.java:69)
at org.sonarsource.scanner.cli.Main.execute(Main.java:69)
##[error]at org.sonarsource.scanner.cli.Main.main(Main.java:61)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Process returned exit code 1
##[error]The SonarScanner did not complete successfully
The SonarScanner did not complete successfully
##[error]06:01:15.693 Post-processing failed. Exit code: 1
06:01:15.693 Post-processing failed. Exit code: 1
##[error]The process 'C:\a\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\5.4.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1
Finishing: Run Code Analysis

How do we troubleshoot or fix this?

Hi,

Could you share your procedure? You are running the prepare step and doing a full re-build, right?

 
Ann

Yes, we do a full re-build. These are the relevant tasks executed in the same order -

- task: SonarQubePrepare@5
  displayName: 'Prepare analysis on SonarQube'

- task: VSBuild@1
  displayName: 'Build Website'

- task: DotNetCoreCLI@2
  displayName: 'Build Service'

- task: CopyFiles@2
  displayName: 'Copy Service to Staging'

- task: CopyFiles@2
  displayName: 'Copy Module to Staging'

- task: CopyFiles@2
  displayName: 'Copy Module to Staging'

- task: DotNetCoreCLI@2
  displayName: Install dotnet-ef
  inputs:
    command: 'custom'
    custom: 'tool'
    arguments: 'install --global dotnet-ef'

- script: 'dotnet ef --startup-project <name> migrations bundle --configuration Bundle --verbose'
  workingDirectory: '$(System.DefaultWorkingDirectory)/src/<name>'
  displayName: 'Create Migrations Bundle'

- task: SonarQubeAnalyze@5
  displayName: 'Run Code Analysis'

- task: SonarQubePublish@5
  displayName: 'Publish Quality Gate Result'

@ganncamp, any update for me?

Hello @gischethans

It seems that there is some generated code in a temporary folder that is failing the build. Are you aware of something in your codebase that generates the files in the temporary folder?

Can you move the “Create Migrations Bundle” task after the analysis?

Share the Scanner for .NET verbose logs

  • Add /d:"sonar.verbose=true" to the…
    • SonarScanner.MSBuild.exe or dotnet sonarscanner begin command to get more detailed logs
      • For example: SonarScanner.MSBuild.exe begin /k:"MyProject" /d:"sonar.verbose=true"
    • “SonarQubePrepare” or “SonarCloudPrepare” task’s extraProperties argument if you are using Azure DevOps
      • For example:
        - task: SonarCloudPrepare@1
            inputs:
              SonarCloud: 'sonarcloud'
              organization: 'foo'
              scannerMode: 'MSBuild'
              projectKey: 'foo_sonar-scanning-someconsoleapp'
              projectName: 'sonar-scanning-someconsoleapp'
              extraProperties: |
                sonar.verbose=true
        
  • The important logs are in the END step (i.e. SonarQubeAnalyze / SonarCloudAnalyze / “Run Code Analysis”)

Share the msbuild detailed logs

MsBuild.exe /t:Rebuild /v:d

or

dotnet build -v:d

Thanks, @Caba_Sagi. Is there a way to share the logs privately?

Hello @gischethans

You can share your logs at the following location: https://community.sonarsource.com/t/re-java-lang-illegalstateexception-the-base-directory-of-the-module-does-not-exist/64292

Moving the ‘Create Migrations Bundle’ task fixed it. Thanks, @Caba_Sagi

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.