SonarQube fails to analyze dotnet core code with error Duplicate ProjectGuid: “00000000-0000-0000-0000-000000000000”

After making some changes to the build definition of one of the dotnet core repositories, we started observing this error with the SonarQube tasks inside the build definition in VSTS:

sonarqube code analysis task failed

When we checked the complete logs, we observed below issue:

2018-09-07T03:09:54.8236958Z WARNING: The following projects do not have a valid ProjectGuid and were not built using a valid solution (.sln) thus will be skipped from analysis…
2018-09-07T03:09:54.9185769Z WARNING: Duplicate ProjectGuid: “00000000-0000-0000-0000-000000000000”. The project will not be analyzed by SonarQube. Project file: “D:\a\1\s\xx\xx.csproj”
2018-09-07T03:09:54.9187236Z WARNING: Duplicate ProjectGuid: “00000000-0000-0000-0000-000000000000”. The project will not be analyzed by SonarQube. Project file: “D:\a\1\s\xx\xx.csproj”
2018-09-07T03:09:54.9187871Z WARNING: Duplicate ProjectGuid: “00000000-0000-0000-0000-000000000000”. The project will not be analyzed by SonarQube. Project file: “D:\a\1\sxx\sxx.csproj”
2018-09-07T03:09:54.9188705Z WARNING: Duplicate ProjectGuid: “00000000-0000-0000-0000-000000000000”. The project will not be analyzed by SonarQube. Project file: “D:\a\1\s\yyy\yyy.csproj”
2018-09-07T03:09:54.9189254Z WARNING: Duplicate ProjectGuid: “00000000-0000-0000-0000-000000000000”. The project will not be analyzed by SonarQube. Project file: “D:\a\1\s\zzzz\zzzz.csproj”
2

As its pretty clear from first line that we were supposed to build our solution using a Visual Studio Solution file using dotnet core. This was exactly the change that we made. Earlier we were using command dotnet build *.sln and we changed to using **/*.csproj files using dotnet core build tasks.

We checked further and found that unlike .NET framework based project files, dotnet core project files (i.e. csproj files) do not have a project GUID associated with them inside tag PropertyGroup. To fix this, we needed to edit the csproj files to add tags like below:


<PropertyGroup>
<!– other properties here –>
<!– SonarQube needs this –>
<ProjectGuid>{6224c484-3e23-4f06-a749-195c1e478110}</ProjectGuid>
</PropertyGroup>

A visual studio solution file does have project GUIDs to reference to the projects. So that’s why it would not throw error if code was build using solution file.

One thought on “SonarQube fails to analyze dotnet core code with error Duplicate ProjectGuid: “00000000-0000-0000-0000-000000000000”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s