# SonarCloud for C# Framework Project

**URL:** <https://community.sonarsource.com/t/sonarcloud-for-c-framework-project/17132>\
**Category:** SonarQube Cloud\
**Tags:** csharp, sonarqube, sonarqube-cloud, scanner\
**Created:** [November 27, 2019, 11:05am UTC](https://community.sonarsource.com/t/sonarcloud-for-c-framework-project/17132 "2019-11-27T11:05:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![justme](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@justme](https://community.sonarsource.com/u/justme)\
**Post date:** [November 27, 2019, 11:05am UTC](https://community.sonarsource.com/t/sonarcloud-for-c-framework-project/17132/1 "2019-11-27T11:05:56Z")

</div>

Hello 🙂

We have a project that contains two parts. A VScode Client in Typescript and a LSP Server in C# Framework.  
We would like to get it analysed by SonarCloud.  
This works: Client code gets uploaded to SonarCloud and gets analyzed. Works perfectly.  
The Problem: our server code gets also uploaded but sonar does not analyse it. Indeed it kinda thinks its Java. There are also some deep neasted Java files in our project and those gehts analysed. But we don’t want that, we would like to have our c# files analyzed.  
We tried to set some config files from java to cs but that does not work.

How can we tell sonar the right way it should analyse our c# code instand of java?

Thank you very much for your help!

Link SonarCloud: [https://sonarcloud.io/code?id=dafny-server](https://sonarcloud.io/code?id=dafny-server)

GitLab Sonar part in our docker build:

> **Summary**
>
> ARG SonarScanner\_RELEASE=3.0.3.778
> 
> RUN curl -o sonarscanner.zip -L [https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-](https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-){SonarScanner\_RELEASE}-linux.zip && \ unzip sonarscanner.zip && \ rm sonarscanner.zip && \ mv sonar-scanner-{SonarScanner\_RELEASE}-linux sonar-scanner  
> ENV PATH=$PATH:/opt/sonar-scanner/bin
> 
> ENV SONAR\_RUNNER\_HOME=/opt/sonar-scanner

GitLab sonar-project.properties

> **Summary**
>
> sonar.host.url=https://sonarcloud.io  
> sonar.organization=hsr  
> sonar.projectKey=dafny-server  
> sonar.projectName=Dafny Server  
> sonar.projectVersion=1.0
> 
> # client und server trennen
> 
> sonar.modules=clientplugin-module, server-module
> 
> # client teil für TS
> 
> clientplugin-module.sonar.projectName=Client Plugin  
> clientplugin-module.sonar.projectBaseDir=VSCodePlugin  
> clientplugin-module.sonar.sources=src  
> clientplugin-module.sonar.tests=test  
> clientplugin-module.sonar.language=ts  
> clientplugin-module.sonar.ts.tslint.path=node\_modules/.bin/tslint
> 
> # server teil für C#
> 
> server-module.sonar.language=cs  
> server-module.sonar.projectName=LSP Server  
> server-module.sonar.projectBaseDir=dafny  
> server-module.sonar.sources=Source  
> server-module.sonar.binaries=Binaries  
> server-module.sonar.tests=Test  
> server-module.sonar.dotnet.visualstudio.solution.file=Dafny.sln  
> server-module.sonar.java.binaries = Binaries

GitLab Yaml:

> **Summary**
>
> variables:  
> BUILD\_IMAGE: $CI\_REGISTRY\_IMAGE/dafny-linux-mono-build  
> NUnitRunner: NUnit.ConsoleRunner.3.10.0/tools/nunit3-console.exe  
> NUnitNugetPackage: nunit.consolerunner
> 
> stages:
> 
> - prebuild
> - build
> - test
> - sonar
> 
> cache:  
> key: ${CI\_COMMIT\_REF\_SLUG}  
> paths:
> 
> - VSCodePlugin/node\_modules/
> 
> build\_image:  
> stage: prebuild  
> image: docker:latest  
> only:  
> refs:  
> - master  
> changes:  
> - Dockerfile.build  
> - .gitlab-ci.yml  
> script:  
> - docker login -u gitlab-ci-token -p $CI\_JOB\_TOKEN $CI\_REGISTRY  
> - docker build --tag $BUILD\_IMAGE:latest - \< Dockerfile.build  
> - docker push $BUILD\_IMAGE:latest
> 
> build\_dafny:  
> stage: build  
> image: $BUILD\_IMAGE:latest  
> script:  
> - if [! -e boogie];  
> then ln -s /opt/boogie;  
> fi;  
> - cd dafny/Source  
> - nuget restore Dafny.sln  
> - msbuild Dafny.sln  
> artifacts:  
> paths:  
> - dafny/Binaries/
> 
> sonar\_test:  
> stage: sonar  
> image: $BUILD\_IMAGE:latest  
> only:  
> - master@dafny-sa/dafny-server-redesign  
> script:  
> - sonar-scanner
> 
> build\_vscode\_extension:  
> stage: build  
> image: $BUILD\_IMAGE:latest  
> script:  
> - cd VSCodePlugin  
> - npm install  
> - npm run vscode:prepublish  
> artifacts:  
> paths:  
> - VSCodePlugin/out/
> 
> test\_nunit:  
> stage: test  
> image: $BUILD\_IMAGE:latest  
> script:  
> - pushd dafny/Binaries; ln -s /opt/z3; popd  
> - cd dafny/Binaries/  
> - nuget install nunit.consolerunner  
> - mono ./$NUnitRunner FileHelperTests.dll  
> - mono ./$NUnitRunner CompletionHandlerTest.dll  
> - mono ./$NUnitRunner VerificationServiceTest.dll  
> - mono ./$NUnitRunner CompileHandlerTest.dll  
> - mono ./$NUnitRunner CounterExampleTest.dll  
> artifacts:  
> reports:  
> junit: dafny/Binaries/TestResult.xml
> 
> test\_vscode\_xvfb:  
> stage: test  
> image: $BUILD\_IMAGE:latest  
> script:  
> - |  
> Xvfb :99 -ac -screen 0 XVFB\_WHD -nolisten tcp 2\>&1 | grep -v "\_XSERVTransmkdir: ERROR: euid != 0,directory /tmp/.X11-unix will not be created." & xvfb=!  
> for i in (seq 1 10); do echo "Waiting for Xvfb..." sleep 1 xdpyinfo -display {DISPLAY} \>/dev/null 2\>&1  
> if [$? -eq 0]; then break; fi  
> if [“$i” -gt 9]; then echo “Waiting for Xvfb timed out. (Waited for $i seconds)”; exit 255; fi  
> done  
> - cd VSCodePlugin  
> - npm install  
> - npm run test
> 
> test\_dafny:  
> stage: test  
> image: $BUILD\_IMAGE:latest  
> script:  
> - cd dafny  
> - pushd Binaries; ln -s /opt/z3; popd  
> - npm install bignumber.js #TODO: Should this be global or in build dependency? Else package.json with fixed versions!  
> - cd Test  
> - “find . -name ‘_.dfy’ -not -path './compileHandlerFiles/_’ -not -path ‘./CounterExampleFiles/\*’ -exec sed -i ‘s!/optimize !!g’ {} +”  
> - lit --time-tests -v .

---

<div class="post-metadata">

**Author:** ![mickaelcaro](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/mickaelcaro/32/4147_2.png) [@mickaelcaro](https://community.sonarsource.com/u/mickaelcaro)\
**Post date:** [November 28, 2019, 7:40am UTC](https://community.sonarsource.com/t/sonarcloud-for-c-framework-project/17132/3 "2019-11-28T07:40:35Z")

</div>

Hi @justme and welcome to the community !

The C# code base can only be analysed with the Scanner for MSBuild, it won’t fail with the standard scanner, but no issues will be raised on SonarCloud.

That being said, you will have to create 2 different projects on SonarCloud, and analyze you codebase twice (one for the java/js codebase, one for C#) in order to get proper analysis result.

Thank you.

Mickaël

---

<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:** [January 29, 2020, 11:32am UTC](https://community.sonarsource.com/t/sonarcloud-for-c-framework-project/17132/4 "2020-01-29T11:32:01Z")

</div>

Split this topic on January 29, 2020, 11:32am UTC

A post was split to a new topic: [Analysing C# in the cloud](https://community.sonarsource.com/t/analysing-c-in-the-cloud/19375)
