The project does not have a valid ProjectGuid causes build to fail

ALM used: Azure DevOps

CI system used: Azure DevOps

SonarCloud Tooling tasks.

  • SonarCloudPrepare@2
    Scanner Version: 9.0.0.100868 (also experienced in v8)
    ScannerMode: MSBuild

  • SonarCloudAnalyze@2
    JDK version: JAVA_HOME_21_X64

  • SonarCloudPublish@2

Languages of the repository: C#

NET 8, C#

Error observed

Building a solution that has a reference to a class lib (All is NET 8)
The build fails when building the Class Lib with the error that the project does not have a valid GUID.
See error details below.

2024-10-14T05:05:31.9777693Z ##[debug]Processed: ##vso[task.logdetail id=f93c51be-4afc-4546-a594-cac4bbba74b7;parentid=;name=SonarQube.Integration.targets;type=Build;starttime=2024-10-14T05:05:30.4262925Z;state=InProgress;]
2024-10-14T05:05:32.0005078Z ##[error]/home/vsts/work/1/.sonarqube/bin/targets/SonarQube.Integration.targets(373,5): Error : The project does not have a valid ProjectGuid. Analysis results for this project will not be uploaded. Project file: /home/vsts/work/1/s/src/OBFUSCATED.Serilog/OBFUSCATED.Serilog/OBFUSCATED.Serilog.csproj
2024-10-14T05:05:32.0135945Z ##[debug]Processed: ##vso[task.logissue type=Error;sourcepath=/home/vsts/work/1/.sonarqube/bin/targets/SonarQube.Integration.targets;linenumber=373;columnnumber=5;code=;]The project does not have a valid ProjectGuid. Analysis results for this project will not be uploaded. Project file: /home/vsts/work/1/s/src/OBFUSCATED.Serilog/OBFUSCATED.Serilog/OBFUSCATED.Serilog.csproj
2024-10-14T05:05:32.0139016Z ##[debug]Processed: ##vso[task.logdetail id=f93c51be-4afc-4546-a594-cac4bbba74b7;parentid=;type=Build;result=Failed;finishtime=2024-10-14T05:05:30.4344376Z;progress=100;state=Completed;parentid=;name=;]
2024-10-14T05:05:32.0139837Z 05:05:30.423   4:2>/home/vsts/work/1/.sonarqube/bin/targets/SonarQube.Integration.targets(373,5): error : The project does not have a valid ProjectGuid. Analysis results for this project will not be uploaded. Project file: /home/vsts/work/1/s/src/OBFUSCATED.Serilog/OBFUSCATED.Serilog/OBFUSCATED.Serilog.csproj [/home/vsts/work/1/s/src/OBFUSCATED.Serilog/OBFUSCATED.Serilog/OBFUSCATED.Serilog.csproj]
2024-10-14T05:05:32.0141203Z                      Assembly loaded during TaskRun (SonarScanner.MSBuild.Tasks.WriteProjectInfoFile): System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 (location: /usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.8/System.Runtime.Serialization.dll, MVID: 64febcfc-7680-493a-9ce5-19ca0f2e9947, AssemblyLoadContext: Default) (TaskId:149)
2024-10-14T05:05:32.0142313Z                      Assembly loaded during TaskRun (SonarScanner.MSBuild.Tasks.WriteProjectInfoFile): Microsoft.GeneratedCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null (location: , MVID: a64f8864-e5db-4733-b2bb-3ac5fafa7b2b, AssemblyLoadContext: MSBuild plugin /home/vsts/work/1/.sonarqube/bin/SonarScanner.MSBuild.Tasks.dll) (TaskId:149)
2024-10-14T05:05:32.0142849Z                    Done executing task "WriteProjectInfoFile". (TaskId:149)
2024-10-14T05:05:32.0143117Z                    Task "Message" (TaskId:150)
2024-10-14T05:05:32.0143427Z                      Task Parameter:Text=Sonar: (OBFUSCATED.Serilog.csproj) Project processed successfully (TaskId:150)
2024-10-14T05:05:32.0143766Z                      Task Parameter:Importance=high (TaskId:150)
2024-10-14T05:05:32.0144076Z                      Sonar: (OBFUSCATED.Serilog.csproj) Project processed successfully (TaskId:150)
2024-10-14T05:05:32.0144372Z                    Done executing task "Message". (TaskId:150) 

Full diagnostic log uploaded to file.io as zip file.
It seems it is not possible to upload zip files here and diag logs are very big and are bigger than. you allow.
Get log here (Available for 2 weeks max)
https://file.io/dkfxxZ4QQ1cJ

CSPROJ for problematic class lib

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFramework>net8.0</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
        <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
        <GenerateDocumentationFile>true</GenerateDocumentationFile>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="Ardalis.GuardClauses" Version="5.0.0" />
        <PackageReference Include="Azure.Monitor.OpenTelemetry.AspNetCore" Version="1.2.0"/>
        <PackageReference Include="Azure.Monitor.OpenTelemetry.Exporter" Version="1.3.0" />
        <PackageReference Include="Microsoft.Azure.Functions.Worker.OpenTelemetry" Version="1.0.0-preview1" />
        <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
        <PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.9.0" />
        <PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.9.0" />
        <PackageReference Include="Serilog" Version="4.0.0" />
        <PackageReference Include="Serilog.AspNetCore" Version="8.0.2"/>
        <PackageReference Include="Serilog.Sinks.Seq" Version="8.0.0"/>
        <PackageReference Include="Serilog.Sinks.ApplicationInsights" Version="4.0.0"/>
    </ItemGroup>
    

</Project>

Steps to reproduce

  • Create NET 8 solution (Minimal API f.ex)
  • Create Class Lib
  • Create reference from primary project to class lib
  • Build using the SLN file in Azure devops. and DO NOT ALLOW WARNINGS

Potential workaround

  • Allow warnings and the build succeeds

Hi @tlogik,

Thanks for the feedback.

This is a known problem that was fixed in the latest scanner version (v9).

Since v9, we only show an INFO message and not a warning.

Regarding your logs, I could not find the BEGIN step that prints the version, but instead, I found this, which suggests that you are using the scanner’s v6.2.0 version:

Assembly loaded during TaskRun: SonarScanner.MSBuild.Tasks, Version=6.2.0.0

Hi @costin.zaharia

Sorry - it seems I have reported something wrong here.
Im the author of the issue
https://community.sonarsource.com/t/re-azure-functions-project-fails-analysis/124464
which in some sense was a factor for some of the changes to v9 which i appreciate.

In this case i thought i had my pipeline setup for v9 but in fact, as you found, i was running v6.
I changed to V9 and no more issues.

I apologize and if we ever meet I owe you a beer :slight_smile:

Ill close this issue as resolved asap

1 Like

Hey, no worries, I’m happy the problem is solved now.

Best,

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