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
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 .
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
@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
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.
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)
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.
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:
Create minimal MAUI project targeting .Net 8 by using command dotnet new maui - problem reproduced
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
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.
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.