Trying to use SonnarScanner for MSBuild

Hello Jenkins community. I’m new here. I’m using jenkins few weeks ago. I tried everything I could but this error still happening. My Jenkins server is running in a oracle linux 8.2 VM. I set up my project in jenkins as free style project. Configuring my project in Build section I set the step SonarScanner for MSBuild - Begin Analysis, then End Analysis. I configured the SonarScanner for MSBuild in the Global Tool Configuration with SonarScanner for MSBuild - .NET 5.0. When I click on build now the poject I got the next error:

FATAL: Cannot run program “dotnet” (in directory “/var/jenkins_home/workspace/test_project”): error=2, No such file or directory error=2, No such file or directory
at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
at java.base/java.lang.ProcessImpl.(
at java.base/java.lang.ProcessImpl.start(
at java.base/java.lang.ProcessBuilder.start(
Caused: Cannot run program “dotnet” (in directory “/var/jenkins_home/workspace/test_project”): error=2, No such file or directory

I don’t know what to do… Is SonarScanner for MSBuild working wrong in jenkins?

Possibly related TODO comment: sonarqube-plugin/ at a0354923a905e6d3015cd9b58018f55661ed537b · jenkinsci/sonarqube-plugin · GitHub

According to that code, the plugin tries to run “dotnet” without specifying a path, and assumes that Launcher finds the executable by searching the directories listed in the PATH environment variable.

Did you install the .NET 5 SDK in such a way that the “dotnet” executable is somewhere on the PATH? Perhaps you should add its installation directory to the PATH environment variable.

Does your freestyle project use “dotnet” for the build itself, and would that part work OK if you removed the sonarqube steps?

I didn’t find a Jira issue corresponding to the TODO comment but [JENKINS-65531] sonar scanner for msbuild with dotnet core 5 - Jenkins Jira at least mentions using sonarqube with msbuild.