"Unrecognized option: begin"

  • which versions are you using
    SonarQube: 9.2.0
  • what are you trying to achieve
    run sonarscanner on a unity project (.net 4.7.1) with mono inside a docker container
  • what have you tried so far to achieve this
    built a docker image like this:
  1. built from unityci/editor:2020.3.1f1-android-0.15, then install mono-devel
  2. downloaded from
    https://github.com/SonarSource/sonar-scanner-msbuild/releases/download/, unzip, make executable, add /sonar-scanner- to PATH
    the image builts fine and everysthing works so far.

Now the following is part of a bash script which is executed by gitlab ci inside a container with that image:

sonar-scanner -X \
      -D sonar.projectKey="$SONAR_PROJECT_KEY" \
      -D sonar.host.url="$SONAR_HOST_URL" \
      -D sonar.login="$SONAR_TOKEN" \
      -D sonar.projectVersion="$CI_PIPELINE_ID" \
      -D sonar.exclusions=../Assets/**/Plugins/**/* \
msbuild ../Assembly-CSharp-Editor.csproj
msbuild ../Assembly-CSharp.csproj
sonar-scanner -D sonar.login="$SONAR_TOKEN" end

The first command fails stating

ERROR: Unrecognized option: begin
INFO: usage: sonar-scanner [options]
INFO: Options:
INFO: -D,–define Define property
INFO: -h,–help Display help information
INFO: -v,–version Display version information
INFO: -X,–debug Produce execution debug output

It took me some time to even get the command to not fail with a -k or -v option - because these are also invalid. I cannot find any guide or tutorial regarding this weird version of the sonar-scanner, everything I see looks entirely different.
Do I have a wrong version of the scanner? Or how am I supposed to use that one?

I think my mistake was to use


instead I have to use

mono sonar-scanner-

I was looking at the docs for sonarscanner-for-msbuild while /bin/sonar-scanner apparently is the scanner to use when there is no specific scanner for the bujild system