AzureDevops pipeline reports invalid project guid for temp generated workerextensions.csproj

I have a .NET solution which contains an azure function app project. When I run this AzureDevops pipeline task, I get the following error message. I have tried setting the sonar.projectBaseDir so that the temporary generated solution will be excluded, but it seems to have no effect.

  - task: SonarCloudPrepare@1
    inputs:
      SonarCloud: "SonarCloud_POC"
      organization: redacted
      scannerMode: "MSBuild"
      projectKey: ${{ parameters.sonarProjectKey }}
      projectName: ${{ parameters.projectName }}
      extraProperties: |
        sonar.projectBaseDir=$(build.SourcesDirectory)
        sonar.cs.opencover.reportsPaths=$(build.SourcesDirectory)/coverage/**/coverage.opencover.xml
        sonar.exclusions=**/packages/**,**/bin/**,**/obj/**,**/*.dll
  WorkerExtensions -> C:\Users\VssAdministrator\AppData\Local\Temp\sjcko3ut.bvd\buildout\Microsoft.Azure.Functions.Worker.Extensions.dll
##[warning]D:\a\1\.sonarqube\bin\targets\SonarQube.Integration.targets(369,5): Warning : The project does not have a valid ProjectGuid. Analysis results for this project will not be uploaded. Project file: C:\Users\VssAdministrator\AppData\Local\Temp\sjcko3ut.bvd\WorkerExtensions.csproj
D:\a\1\.sonarqube\bin\targets\SonarQube.Integration.targets(369,5): warning : The project does not have a valid ProjectGuid. Analysis results for this project will not be uploaded. Project file: C:\Users\VssAdministrator\AppData\Local\Temp\sjcko3ut.bvd\WorkerExtensions.csproj [C:\Users\VssAdministrator\AppData\Local\Temp\sjcko3ut.bvd\WorkerExtensions.csproj]

Hey there.

Does this actually fail your analysis, or are you only trying to get rid of the warning?

I’m trying to get rid of the warning. The analysis appears to run successfully.

1 Like

I’ve flagged this for some attention.

Hello @chaoticnadirs

Could you please share the msbuild detailed logs ?

MsBuild.exe /t:Rebuild /v:d

or

dotnet build -v:d

Does this project have a project guid set and if yes, could you share it with us?

The build logs are attached. The project that throws the warning is an auto-generated project. I don’t have the option to assign a project guid.

build-log.txt (3.1 MB)

Hello @chaoticnadirs

What I saw from the logs is that it is not us generating the invalid GUID.
It should be that the generated WorkerExtensions.csproj project for whatever reason has an invalid ProjectGuid.

Could you please provide us with the binary diagnostic level logs of the build? This should let us see the project GUID and understand what is the problem with its format.

To create the binary logs you have to use the -bl switch. For more information take a look at the documentation.

We have the same problem.
You can reproduce it by creating a azure functions app that run in isolated mode.

Since this have been a problem for 8 month we fixed local.
by creating a powershell script that update file: .sonarqube\bin\targets\SonarQube.Integration.targets

Like this:

$xml = [xml](Get-Content $sonarQubeIntegrationTargetsPath)
$SonarWriteProjectData = ($xml.Project.Target | Where-Object {$_.Name -eq "SonarWriteProjectData" }).PropertyGroup

$node = $xml.CreateElement("ProjectGuid", $SonarWriteProjectData.SchemaInfo.NamespaceURI)
$attribute = $xml.CreateAttribute("Condition")
$attribute.Value = @'
$(ProjectGuid) == '' AND $([System.String]::new('$(MSBuildProjectFullPath)').EndsWith('WorkerExtensions.csproj'))
'@
$node.InnerText = '{$([System.Guid]::NewGuid())}'
$node.Attributes.Append($attribute) | Out-Null

$SonarWriteProjectData.AppendChild($node) | Out-Null

$xml.Save($sonarQubeIntegrationTargetsPath)