Yesterday I talked about setting up Sonar Cloud for code analysis.
Unfortunately it turned out to be not so simple as I expected. The first time I ran the build pipeline the Code analysis task failed with the following error:
2020-09-14T17:47:52.6441174Z ##[section]Starting: Run Code Analysis
2020-09-14T17:47:52.6563714Z ==============================================================================
2020-09-14T17:47:52.6564026Z Task : Run Code Analysis
2020-09-14T17:47:52.6564329Z Description : Run scanner and upload the results to the SonarCloud server.
2020-09-14T17:47:52.6564583Z Version : 1.15.0
2020-09-14T17:47:52.6564794Z Author : sonarsource
2020-09-14T17:47:52.6565319Z Help : Version: 1.15.0. This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.
[More Information](https://sonarcloud.io/documentation/analysis/scan/sonarscanner-for-azure-devops/)
2020-09-14T17:47:52.6565909Z ==============================================================================
2020-09-14T17:47:52.9698863Z [command]D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.12.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe end
2020-09-14T17:47:53.0469811Z SonarScanner for MSBuild 4.10
2020-09-14T17:47:53.0470290Z Using the .NET Framework version of the Scanner for MSBuild
2020-09-14T17:47:53.0984270Z Post-processing started.
2020-09-14T17:47:54.3358218Z WARNING: Duplicate ProjectGuid: "00000000-0000-0000-0000-000000000000". The project will not be analyzed by SonarQube. Project file: "d:\a\1\s\bridges.cms.modules.contentcreation.shared\bridges.cms.modules.contentcreation.shared.csproj"
2020-09-14T17:47:54.3359968Z WARNING: Duplicate ProjectGuid: "00000000-0000-0000-0000-000000000000". The project will not be analyzed by SonarQube. Project file: "d:\a\1\s\bridges.cms.modules.contentcreation.infrastructure\bridges.cms.modules.contentcreation.infrastructure.csproj"
2020-09-14T17:47:54.3361069Z WARNING: Duplicate ProjectGuid: "00000000-0000-0000-0000-000000000000". The project will not be analyzed by SonarQube. Project file: "d:\a\1\s\bridges.cms.modules.contentcreation.domain\bridges.cms.modules.contentcreation.domain.csproj"
2020-09-14T17:47:54.3362264Z WARNING: Duplicate ProjectGuid: "00000000-0000-0000-0000-000000000000". The project will not be analyzed by SonarQube. Project file: "d:\a\1\s\bridges.cms.modules.contentcreation.application\bridges.cms.modules.contentcreation.application.csproj"
2020-09-14T17:47:54.3364005Z WARNING: Duplicate ProjectGuid: "00000000-0000-0000-0000-000000000000". The project will not be analyzed by SonarQube. Project file: "d:\a\1\s\bridges.cms.modules.contentcreation.dataaccess\bridges.cms.modules.contentcreation.dataaccess.csproj"
2020-09-14T17:47:54.3365002Z WARNING: Duplicate ProjectGuid: "00000000-0000-0000-0000-000000000000". The project will not be analyzed by SonarQube. Project file: "d:\a\1\s\bridges.cms.modules.contentcreation.archtests\bridges.cms.modules.contentcreation.archtests.csproj"
2020-09-14T17:47:54.3366234Z WARNING: Duplicate ProjectGuid: "00000000-0000-0000-0000-000000000000". The project will not be analyzed by SonarQube. Project file: "d:\a\1\s\bridges.cms.modules.contentcreation.integrationtests\bridges.cms.modules.contentcreation.integrationtests.csproj"
2020-09-14T17:47:54.3367348Z WARNING: Duplicate ProjectGuid: "00000000-0000-0000-0000-000000000000". The project will not be analyzed by SonarQube. Project file: "d:\a\1\s\bridges.cms.api\bridges.cms.api.csproj"
2020-09-14T17:47:54.3368778Z WARNING: Duplicate ProjectGuid: "00000000-0000-0000-0000-000000000000". The project will not be analyzed by SonarQube. Project file: "d:\a\1\s\bridges.cms.modules.contentcreation.unittests\bridges.cms.modules.contentcreation.unittests.csproj"
2020-09-14T17:47:54.3370405Z ##[error]No analysable projects were found. SonarQube analysis will not be performed. Check the build summary report for details.
2020-09-14T17:47:54.3371973Z No analysable projects were found. SonarQube analysis will not be performed. Check the build summary report for details.
2020-09-14T17:47:54.3431567Z Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.
2020-09-14T17:47:54.3479798Z ##[error]17:47:54.346 Post-processing failed. Exit code: 1
2020-09-14T17:47:54.3481669Z 17:47:54.346 Post-processing failed. Exit code: 1
2020-09-14T17:47:54.3668330Z ##[error]The process 'D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.12.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1
2020-09-14T17:47:54.3739014Z ##[section]Finishing: Run Code Analysis
The problem is that SonarCloud expects a ProjectGuid to be able to differentiate between the different C# projects(.csproj files ) I have in my source repository. As this are .NET Core projects such a ProjectGuid no longer exist.
To solve this problem I changed my dotnet build task to use the solution file instead of using csproj files: