Problem scanning .NET 8 targeted projects on MacOS

We updated our build environment to try out .NET 8.0.0-preview.7.23375.6. Since then the sonarqube scanner fails with this error message in the “end” step (the “begin” and “build” step are executed successfully). Does Sonarqube support .NET 8 targeted projects and does it support builds that were created with MSBuild version 17.8 (Breaking change: Version requirements for .NET 8 SDK - .NET | Microsoft Learn)?

[1;34m==> dotnet /Users/Shared/Applications/sonar-scanner-msbuild-net5.0/SonarScanner.MSBuild.dll end /d:sonar.login=***e[m
build	13-Sep-2023 15:58:04	SonarScanner for MSBuild 5.13.1
build	13-Sep-2023 15:58:04	Using the .NET Core version of the Scanner for MSBuild
build	13-Sep-2023 15:58:04	Post-processing started.
error	13-Sep-2023 15:58:04	15:58:04.902  The SonarScanner for MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
build	13-Sep-2023 15:58:04	15:58:04.902  Generation of the sonar-properties file failed. Unable to complete the analysis.
error	13-Sep-2023 15:58:04	Possible causes:
error	13-Sep-2023 15:58:04	  1. The project has not been built - the project must be built in between the begin and end steps
error	13-Sep-2023 15:58:04	  2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0.25420.1 and higher are supported.
error	13-Sep-2023 15:58:04	  3. The begin, build and end steps have not all been launched from the same folder
error	13-Sep-2023 15:58:04	  4. None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)
error	13-Sep-2023 15:58:04	15:58:04.912  Post-processing failed. Exit code: 1

Must-share information (formatted with Markdown):

  • which versions are you using: SonarScanner for MSBuild 5.13.1
  • how is SonarQube deployed: zip
  • what are you trying to achieve: scan .NET 8 targeted project (8.0.0-preview.7.23375.6)
2 Likes

Hello @Christopher_Stephan

I just tried to analyze a class library that targets .NET 8.0.100-rc.1.23455.8 and it works.
Can you share please what type of project you analyze?

Best,
Čaba

Hi Čaba

we are analyzing a .NET MAUI Class Library that targets net8; net8.0-android; net8.0-ios.

Regards
Christopher

Hmm, I did an analysis of a .NET MAUI class library targeting .net 8 and it works for me.

Can you please provide me with the verbose level logs of the build in binary log format?
To get the logs you will need the following parameters: /v:d -bl:build.binlog .

Hi Čaba,

can you send me your mail? It would like to send the log in a mail, because there is too much project related information in the log.

Any updates on this issue?

@Christopher_Stephan @SimonB hello - sorry for the delay.

What Operating Systems are you using to do the analysis?

Thanks for the reply! Were using Mac OS 13.4

@Christopher_Stephan @SimonB
Apologies for the delay. I am taking over on this issue.

Here is a quick update:

  • we have internal users also being able to reproduce the issue
  • it doesn’t seem to come from MAUI, and it’s rather MacOS-specific
  • we tested on Windows and Linux, and could not reproduce it in any scenario
  • we are now going to test on MacOS

@Christopher_Stephan I have sent you a personal message here on the community platform, to securely get your logs.

Thanks,
Antonio

1 Like

I’m trying to get coverage from a dotnet 8 MAUI project but I’m getting the same error as the OP says.
In my case the project is net8.0;net8.0-android; the test project is net8.0 and the virtual machine that host the compilation agents is Linux.

Any ideas? I can provide any aditional information gladly

Edit: Nevermind, it was an error in my pipeline :sweat_smile:

@SimonB @Christopher_Stephan
Hi, I have been trying to run analyses from a MacBook Pro, equipped with macOS Ventura 13.6 and a 2.6 GHz 6-Core Intel Core i7, but I could not reproduce the issue. Neither with a minimal .NET 8 console project (created via dotnet new console) nor with a minimal .NET 8 maui project (created via dotnet new maui).
I would need another piece of information to continue this investigation: what architecture are you running MacOS on?
Is it an Intel x64 architecture, or an arm64?
Thanks a lot for your help,
Antonio

Hi @ antonio.aversa, were using both. But our automated builds (currently) are running on an intelx64 (2018 MacMini 3,2 GHz, 64Gb RAM, Ventura 13.4.1)

Could you tell us what you fixed on your pipeline to make it work?

We have the same issue while building a Maui Project. Pipeline runner is using macOS Sonoma 14.0 on arm64.

dotnet --version
8.0.100-rc.2.23502.2

dotnet-sonarscanner --version
SonarScanner for MSBuild 5.14

I’m highly interested in a solution for this and eager to help!

3 Likes

Hi,

We are also struggling with the same problem. We have .Net MAUI project and we just migrated from .Net 7 to .Net 8 (RC2). After the migration, immediately we started to have mentioned problem.

We are using SonarCloud and analysis is a part of Azure DevOps pipeline (on Microsoft-hosted agents running MacOS). However I was able to reproduce it on my MacBook Pro (2,3 GHz 8-Core Intel Core i9, Ventura 13.5.2).
I am able to reproduce it on our MAUI project as well as on minimal project created via dotnet new maui.

We are also highly interested in a solution and we would like to help.

2 Likes

To be sure I just checked, I have the same behaviour when running dotnet-sonarscanner on the Maui Sample Project.

 1. The project has not been built - the project must be built in between the begin and end steps
  2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0.25420.1 and higher are supported.
  3. The begin, build and end steps have not all been launched from the same folder
  4. None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)
2 Likes

Hi,
I am still investigating, but I wanted to give you some updates.
It seems that the root cause of the issue is this breaking change of GetFolderPath behavior in macOS with LocalApplicationData.

It used to point to $HOME/.local/share and now points to $HOME/Library/Application Support.

While I can’t reproduce the problem yet on my macOS Ventura 13.6 Intel with .net8 8.0.100-rc.2.23502.2 and MSBuild 5.13.1 against SonarCloud, we have a macOS user reproducing the issues internally, and I am trying to understand what are the differences between the two setups.

I will keep you posted,
Antonio

2 Likes

Hi,

Probably it could be helpful in reproduction, but I have walked in a backward direction (from state where I have a problem to a working state). I am working on MacOS and using dotnet-sonarscanner combined with SonarCloud. Below you can se steps:

  1. Create minimal MAUI project targeting .Net 8 by using command dotnet new maui - problem reproduced
  2. In project file change target framework to .Net7 (from net8.0-XXX to net7.0-XXX). In addition I need to remove or change version of some referenced NuGet packages - problem still can be reproduced
  3. Change used .Net SDK version to 7.0.x by adding global.json file (see Select which .NET version to use - .NET | Microsoft Learn). I addition then I need to install workloads again - problem disappears
2 Likes

Hi again,

I have more information to provide and a temporary workaround.

I can finally reproduce the issue on my macOS machine, and I confirm it comes from this breaking change of GetFolderPath, introduced in .NET 8 Preview 1. If you are interested in the details, you can find more information about it here and here.

In the specific case of the Sonar Scanner, the issue only appears when a previous version of .NET (e.g. .NET 7) has been installed on the machine and the scanner has been run against that version. I could not reproduce the issue before because, on my machine, I hadn’t run the Scanner with a previous version of .NET. Therefore, I had no files under /Users/youruser/.local/share/Microsoft/MSBuild.

A quick temporary workaround that should fix the issue is to move the directory /Users/youruser/.local/share/Microsoft/MSBuild to /Users/youruser/Library/Application Support/Microsoft/MSBuild, and then rerun the analysis.

I am now checking why the Sonar Scanner gets stuck on using /Users/youruser/.local/share/Microsoft/MSBuild, when that is present on the disk, despite LocalApplicationData pointing to the Library/Application Support location.

Hope it helps,
Antonio

4 Likes

Hi @antonio.aversa

I have verified you workaround and it works.

In addition I have found something. When I am calling dotnet sonar scanner begin then it creates files under /Users/youruser/.local/share/Microsoft/MSBuild directory. As I understand, those files should be placed under /Users/youruser/Library/Application Support/Microsoft/MSBuild directory.

So probably here could be an issue: dotnet sonar scanner begin creates files in wrong place.

EDIT: I have made couple tests (by removing files from /Users/youruser/.local/share/Microsoft/MSBuild directory and/or /Users/youruser/Library/Application Support/Microsoft/MSBuild directory) and dotnet sonar scanner begin always creates files only in
/Users/youruser/.local/share/Microsoft/MSBuild directory.

2 Likes