Error when analyzing .NET 6 project on SonarCloud

Hello @Tom_Howlett, thanks for update.

We have tried to run SonarCloudAnalyze@1 Azure DevOps task for our .NET 6 solution and reached strange error, here is screenshot :

We had install both 3.1 and 6.0 SDK’s on agent and don’t forget doing sonar prepare before build.

Can you please advice us what’s can be wrong ?

1 Like

Hello and welcome to the community

I’ve split your message to a new topic to comply with our community guideline (see FAQ - SonarSource Community).

We’ll need the logs:

  • please give us the verbose output of SonarCloudPrepare and SonarCloudAnalyze (see instructions here)
  • please give the output of running MSBuild in verbose mode (/v:d)

Thanks
Andrei

Hello, @Andrei_Epure , Thank you for such quick reply,

here is attached logs, build log I divided to 4 parts because of 4mb limitations for file here

SonarPrepareLog.txt (10.7 KB)
SonarAnalizeLog.txt (121.2 KB)
BuildLog1.txt (2.5 MB)
BuildLog2.txt (2.9 MB)
BuildLog3.txt (2.9 MB)
BuildLog4.txt (1.8 MB)

Looking forward for your advice, thanks you

Hello @Yevhen_Novytskyi

Thanks for the logs.

Error:

2021-11-23T17:48:06.4057901Z 17:48:06.399 ERROR: Error during SonarScanner execution
2021-11-23T17:48:06.4058965Z 17:48:06.399 INFO: ------------------------------------------------------------------------
2021-11-23T17:48:06.4062517Z ##[error]java.lang.IllegalStateException: The base directory of the module ‘3CDBEBBC-503D-4132-BEFC-091554528943’ does not exist: /tmp/jpa5hzfh.grh
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.loadModulesProperties(Conf.java:162)
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.Main.execute(Main.java:69)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)

And from the logs:

3CDBEBBC-503D-4132-BEFC-091554528943.sonar.projectKey=organizationA-services:3CDBEBBC-503D-4132-BEFC-091554528943
2021-11-23T17:48:02.6788139Z 3CDBEBBC-503D-4132-BEFC-091554528943.sonar.projectName=bundle
2021-11-23T17:48:02.6788780Z 3CDBEBBC-503D-4132-BEFC-091554528943.sonar.projectBaseDir=/tmp/jpa5hzfh.grh
2021-11-23T17:48:02.6789580Z 3CDBEBBC-503D-4132-BEFC-091554528943.sonar.sourceEncoding=utf-8
2021-11-23T17:48:02.6790154Z 3CDBEBBC-503D-4132-BEFC-091554528943.sonar.sources=
2021-11-23T17:48:02.6790356Z
2021-11-23T17:48:02.6790454Z

So this project seems to have no sources and to be in a temporary folder. It seems that this is probably auto-generated and after the build it gets deleted.

Could you share more around how you are using the analysis? Are you generating a temporary project during the build? How are you doing that?

If you’d rather have the discussion on a private thread, please let me know, and we can do this on this forum.

A post was split to a new topic: Problem scanning temporary files generated by third-party app

@Yevhen_Novytskyi Are you able to build your .NET 6 solution/project successfully?

I had to update vmImage to ‘windows-2022’ and install .NET 6 SDK for the solution to build successfully in Azure DevOps, see complete yaml file for your reference, hopefully it helps you.

trigger: none

pool:
  vmImage: 'windows-2022'

variables:
  solutionName: 'MySolution'
  solution: '$(solutionName).sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:

# Add this Command to Include the .NET 6 SDK
- task: UseDotNet@2
  displayName: Use .NET 6.0
  inputs:
    packageType: 'sdk'
    version: '6.0.x'

# Add a Command To List the Current .NET SDKs (Sanity Check)
- task: CmdLine@2
  inputs:
    script: 'dotnet --list-sdks'

- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: SonarCloudPrepare@1
  inputs:
    SonarCloud: 'SonarCloud'
    organization: 'MyOrg'
    scannerMode: 'MSBuild'
    projectKey: 'MyProjectKey'
    projectName: 'MyProjectName'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(Build.artifactStagingDirectory)"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: SonarCloudAnalyze@1

- task: SonarCloudPublish@1
  inputs:
    pollingTimeoutSec: '300'
1 Like

This topic was automatically closed after 53 days. New replies are no longer allowed.