[Question] Cannot scan dotnet core project

Must-share information (formatted with Markdown):

dotnet tool install --global dotnet-sonarscanner
dotnet sonarscanner begin /k: "project-key"
dotnet build <path to solution.sln>
dotnet sonarscanner end
but when I exec command dotnet sonarscanner begin /k: "project-key"
Here is the result:

Could not execute because the specified command or file was not found.
Possible reasons for this include:

  • You misspelled a built-in dotnet command.
  • You intended to execute a .NET Core program, but dotnet-sonarscanner does not exist.
  • You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.

Does any khow why? Thanks!

Hello @tuanna2704,

Difficult to be sure but that looks like that:

  • Either your dotnet-sonarscanner installation failed
  • Or you installed a too old version of the dotnet-sonarscanner

Can you try: dotnet tool list -g to check all the installed tools and verify that the dotnet-sonarscanner is installed, in version 4.8

If that’s not the case:

  • If not installed, run install again dotnet tool install --global dotnet-sonarscanner to install and check any possible installation error message
  • If not version 4.8, upgrade with dotnet tool update --global dotnet-sonarscanner

Then let me know where you are.


Hi Olivier Korach. Its haven’t work. Thanks for your supporting. Below is my screen. Maybe it can help.

Sorry for the delay.

You don’t run the scanner with the right command. Please check documentation
This should be:
dotnet sonarscanner begin /k:<myProjectKey>
and not
dotnet dotnet-sonarscanner begin /k:<myProjectKey>

Once you fixed your cmd line you may have another problem: There’s a dotnet strange behaviour (a bug ?) that causes just installed tools to not be immediately accessible to run.
There are quite some posts on the internet about that, with a variety of solutions.
See https://github.com/dotnet/sdk/issues/8999 and https://github.com/dotnet/cli/issues/8369
You may try the recipes given there.

I could also reproduce a similar problem in a docker container.
I had to set the $PATH env variable before the scanner could be used

dotnet tool install dotnet-sonarscanner --global
export PATH="$PATH:/root/.dotnet/tools"
dotnet sonarscanner begin /k:<myProjectKey>

Let me know.

1 Like

A post was split to a new topic: “Could not find ‘java’ executable in JAVA_HOME or PATH.” when scanning with Scanner for NET

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