Hi,
Apologies for the delay. I am following up on this issue.
While I don’t have a full understanding of what is happening yet, I want to give an update on the current state of this investigation.
What I think is now happening is the following:
- As mentioned in a previous investigation here on the community, .NET 8 introduced a breaking change of
LocalApplicationData
location, on MacOS exclusively. This is the location used to place theSonarQube.Integration.ImportBefore.targets
file necessary to run Sonar analyzers during project build. - When the Scanner for .NET is run against .NET 8, it places the
targets
file at the new location. - The build of the MAUI/Xamarin project happens on MSBuild 16.10.1 for Mono.
- This version of MSBuild for Mono runs on .NET 7 or earlier.
- I don’t have any evidence of that yet: I am currently testing.
- MSBuild itself uses the same .NET API that we use to place the
targets
file. - Therefore, it looks in the old location, and it doesn’t find the
targets
file. - As a result, Sonar Analyzers are not executed on the build, resulting in the
SonarQubeAnalyze
error that we can see from the logs.
I am currently trying to recreate a MacOS environment where the actual build happens on .NET 7, even when .NET 8 is available on the machine.
While I am trying to reproduce that, it would be valuable to add the following target to any of the csproj
you build.
<Target Name="DisplayMessages" BeforeTargets="CoreCompile">
<Message Importance="high" Text="[DEBUG] LocalAppData = $(LocalAppData)" />
<Message Importance="high" Text="[DEBUG] MSBuildToolsVersion = $(MSBuildToolsVersion)" />
<Message Importance="high" Text="[DEBUG] TargetFramework = $(TargetFramework)" />
<Message Importance="high" Text="[DEBUG] MSBuildRuntimeVersion = $([System.Runtime.InteropServices.RuntimeInformation]:: FrameworkDescription.ToString())" />
<Message Importance="high" Text="[DEBUG] CLRVersion = $([System.Environment]::Version)" />
</Target>
Those will log some variables, that I would like to know the value of.
If the scenario above matches what’s actually happening in your build, we should be able to provide a fix.
That will however require a new release of the Scanner for .NET.
I hope I will soon be able to provide updates.
Best regards,
Antonio