Dotnet Sonarscanner tool does not find .NET runtime

SonarQube Community Build version: v25.3.0.104237
.NET sonarscanner tool version: 10.1.1
Deployment type: Docker

I am trying to get the dotnet scanner tool working on Linux. I have .NET 8 installed on the machine. Manually running dotnet build works fine.

But trying to start the scan via dotnet sonarscanner begin ... results in the following:

You must install .NET to run this application.

App: /root/.dotnet/tools/dotnet-sonarscanner
Architecture: x64
App host version: 8.0.14
.NET location: Not found

Learn more:
https://aka.ms/dotnet/app-launch-failed

Download the .NET runtime:
https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=linux-x64&os=ubuntu.22.04&apphost_version=8.0.14

But running dotnet --info yields:

.NET SDK:
 Version:           8.0.114
 Commit:            54ac9c88f1
 Workload version:  8.0.100-manifests.20e9918b

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  22.04
 OS Platform: Linux
 RID:         linux-x64
 Base Path:   /root/.dotnet/sdk/8.0.114/

.NET workloads installed:
 Workload version: 8.0.100-manifests.20e9918b
There are no installed workloads to display.

Host:
  Version:      8.0.14
  Architecture: x64
  Commit:       1584e49360

.NET SDKs installed:
  8.0.114 [/root/.dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.14 [/root/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.14 [/root/.dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

Finally, both .dotnet and .dotnet/tools are part of PATH:

# echo $PATH
/opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.dotnet:/root/.dotnet/tools

Silly mistake on my part, but I will provide the solution just in case anyone else stumbles upon the same issue. The problem in my case was that I am installing dotnet via the scripted install provided by Microsoft (Install .NET on Linux without using a package manager - .NET) and I forgot to also set the DOTNET_ROOT environment variable.

Once I set this variable as well, scanning works fine.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.