# "Unrecognized option: begin"

**URL:** <https://community.sonarsource.com/t/unrecognized-option-begin/53849>\
**Category:** SonarQube Server / Community Build\
**Tags:** csharp, msbuild, unity, scanner\
**Created:** [November 26, 2021, 11:58pm UTC](https://community.sonarsource.com/t/unrecognized-option-begin/53849 "2021-11-26T23:58:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![IARI](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/iari/32/27803_2.png) [@IARI](https://community.sonarsource.com/u/IARI)\
**Post date:** [November 26, 2021, 11:58pm UTC](https://community.sonarsource.com/t/unrecognized-option-begin/53849/1 "2021-11-26T23:58:58Z")

</div>

- which versions are you using  
SonarQube: 9.2.0  
Scanner: 4.6.2.2472
- 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/5.4.0.40033/sonar-scanner-msbuild-5.4.0.40033-net46.zip](https://github.com/SonarSource/sonar-scanner-msbuild/releases/download/5.4.0.40033/sonar-scanner-msbuild-5.4.0.40033-net46.zip), unzip, make executable, add /sonar-scanner-4.6.2.2472/bin 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:

```auto
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/** /* \
      begin
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:  
> INFO: usage: sonar-scanner [options]  
> INFO:  
> 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?

---

<div class="post-metadata">

**Author:** ![IARI](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/iari/32/27803_2.png) [@IARI](https://community.sonarsource.com/u/IARI)\
**Post date:** [November 27, 2021, 3:43pm UTC](https://community.sonarsource.com/t/unrecognized-option-begin/53849/2 "2021-11-27T15:43:21Z")

</div>

I think my mistake was to use

> /sonar-scanner-4.6.2.2472/bin/sonar-scanner

instead I have to use

> mono sonar-scanner-4.6.2.2472/SonarScanner.MSBuild.exe

I was looking at the [docs for sonarscanner-for-msbuild](https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-msbuild/) while /bin/sonar-scanner apparently is the [scanner to use when there is no specific scanner for the bujild system](https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/)

---

<div class="post-metadata">

**Author:** ![duncanp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/duncanp/32/293_2.png) [@duncanp](https://community.sonarsource.com/u/duncanp)\
**Post date:** [December 2, 2021, 11:00am UTC](https://community.sonarsource.com/t/unrecognized-option-begin/53849/3 "2021-12-02T11:00:54Z")

</div>

Closed on December 2, 2021, 11:00am UTC


