# Create .gitlab-ci.yml .net project

**URL:** <https://community.sonarsource.com/t/create-gitlab-ci-yml-net-project/75147>\
**Category:** SonarQube Server / Community Build\
**Created:** [October 27, 2022, 8:31am UTC](https://community.sonarsource.com/t/create-gitlab-ci-yml-net-project/75147 "2022-10-27T08:31:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cacaue](https://avatars.discourse-cdn.com/v4/letter/c/f08c70/32.png) [@Cacaue](https://community.sonarsource.com/u/Cacaue)\
**Post date:** [October 27, 2022, 8:31am UTC](https://community.sonarsource.com/t/create-gitlab-ci-yml-net-project/75147/1 "2022-10-27T08:31:54Z")

</div>

I was trying to analise a gitlab project in my sonarqube server, Gitlab onpremise was integrated in sonar  
I created variables in my gitlab project  
I created .gitlab-ci.yml with this content

> sonarqube-check:  
> variables:  
> SONAR\_USER\_HOME: “${CI\_PROJECT\_DIR}/.sonar” # Defines the location of the analysis task cache  
> GIT\_DEPTH: “0” # Tells git to fetch all the branches of the project, required by the analysis task  
> cache:  
> key: “${CI\_JOB\_NAME}”  
> paths:  
> - .sonar/cache  
> script:  
> - “dotnet sonarscanner begin /k:"PROJECT” /d:sonar.login="$SONAR\_TOKEN" /d:"sonar.host.url=$SONAR\_HOST\_URL" "  
> - “dotnet build”  
> - “dotnet sonarscanner end /d:sonar.login="$SONAR\_TOKEN"”  
> allow\_failure: true  
> only:  
> - master # or the name of your main branch

When I executed this command in runner server

> dotnet sonarscanner begin /k:"PROJECT" /d:sonar.login="$SONAR\_TOKEN\

it was succesfull

But in pipeline showed this error

```auto
$ dotnet sonarscanner begin /k:"MYPROJECT" /d:sonar.login="$SONAR_TOKEN" /d:"sonar.host.url=$SONAR_HOST_URL"
No se pudo ejecutar porque no se encontr� el comando o el archivo especificado.

Algunas de las posibles causas son :
Escribi� mal un comando dotnet integrado.
Pretend�a ejecutar un programa .NET, pero dotnet-sonarscanner no existe.
Pretend�a ejecutar una herramienta global, pero no se encontr� ning�n ejecutable con prefijo dotnet con este nombre en PATH.

```

Could you help me? How do you create .gitlab-ci.yml to scan your gitlab projects?

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [October 28, 2022, 10:23am UTC](https://community.sonarsource.com/t/create-gitlab-ci-yml-net-project/75147/2 "2022-10-28T10:23:22Z")

</div>

Hey there.

The tutorial in the UI suggests a YML file that looks like this:

```auto
sonarqube-check:
  image: mcr.microsoft.com/dotnet/core/sdk:latest
  variables:
    SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
    GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
  cache:
    key: "${CI_JOB_NAME}"
    paths:
      - .sonar/cache
  script: 
      - "apt-get update"
      - "apt-get install --yes openjdk-11-jre"
      - "dotnet tool install --global dotnet-sonarscanner"
      - "export PATH=\"$PATH:$HOME/.dotnet/tools\""
      - "dotnet sonarscanner begin /k:\"tewafsdf\" /d:sonar.login=\"$SONAR_TOKEN\" /d:\"sonar.host.url=$SONAR_HOST_URL\" "
      - "dotnet build"
      - "dotnet sonarscanner end /d:sonar.login=\"$SONAR_TOKEN\""
  allow_failure: true
  only:
    - merge_requests
    - master # or the name of your main branch
    - develop

```

So you’re missing some steps, like installing the dotnet-sonarscanner global tool.
