# Problem with C# project analysis

**URL:** <https://community.sonarsource.com/t/problem-with-c-project-analysis/15880>\
**Category:** SonarQube Cloud\
**Tags:** csharp, scanner, sonarqube-cloud\
**Created:** [October 24, 2019, 8:08pm UTC](https://community.sonarsource.com/t/problem-with-c-project-analysis/15880 "2019-10-24T20:08:51Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jakob\_Blume1](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/jakob_blume1/32/7215_2.png) [@Jakob\_Blume1](https://community.sonarsource.com/u/Jakob_Blume1)\
**Post date:** [October 24, 2019, 8:08pm UTC](https://community.sonarsource.com/t/problem-with-c-project-analysis/15880/1 "2019-10-24T20:08:51Z")

</div>

Hello there, i am analyzing a simple c# project, The analysis is running successfully and the data is passed to sonarcloud. But i do not see any measures (lines of code, cyclomatic complexity,…) and do not know what config i missed or what else i can do wrong…

I am working with the ‘dotnet tool install --global dotnet-sonarscanner’ tool and executing the sonar analysis with the following 4 command:

dotnet sonarscanner begin /d:sonar.host.url="$SONAR\_HOST" /d:sonar.sources="$SOURCES" /d:sonar.login="$SONAR\_LOGIN\_KEY" /k:"$PROJECT\_KEY" /o:"$SONAR\_ORGANIZATION"  
dotnet restore  
dotnet build  
dotnet sonarscanner end /d:sonar.login="$SONAR\_LOGIN\_KEY"

I really look forward for your help, because i do not know where to look for a solution for this problem. Does not find any other documented issues like that, except this one:

> <https://stackoverflow.com/questions/31131021/c-project-not-reporting-any-metric-on-sonarqube>

  
But my project does not contain a Test/test in name and to be sure i used the current parameter sonar.msbuild.testProjectPattern to ensure that the project is NOT analysed as a test project.

---

<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:** [October 25, 2019, 6:08am UTC](https://community.sonarsource.com/t/problem-with-c-project-analysis/15880/2 "2019-10-25T06:08:52Z")

</div>

hi @Jakob_Blume1 and welcome to the community !

The Scanner for MSBuild embed its own engine to detect all the source file that it should analyze.

So first thing first, i would suggest to try to invoke the begin step without the sonar.sources and let us know how it goes.

Thank you !

Mickaël

---

<div class="post-metadata">

**Author:** ![Jakob\_Blume1](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/jakob_blume1/32/7215_2.png) [@Jakob\_Blume1](https://community.sonarsource.com/u/Jakob_Blume1)\
**Post date:** [October 25, 2019, 7:03am UTC](https://community.sonarsource.com/t/problem-with-c-project-analysis/15880/3 "2019-10-25T07:03:08Z")

</div>

Hi and thank you for the warm welcome 🙂

This is what i already tried ☹ This sadly does not change the result.

---

<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:** [October 25, 2019, 7:09am UTC](https://community.sonarsource.com/t/problem-with-c-project-analysis/15880/4 "2019-10-25T07:09:27Z")

</div>

Ok, so then could you please send me the logs of the step 'dotnet sonarscanner end /d:sonar.login="$SONAR\_LOGIN\_KEY", in debug mode ? You can enable it by adding the /d:sonar.verbose=true

With redacted stuff if needed, or i can send it to me via PM, just let me know.

Thank you.

---

<div class="post-metadata">

**Author:** ![Jakob\_Blume1](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/jakob_blume1/32/7215_2.png) [@Jakob\_Blume1](https://community.sonarsource.com/u/Jakob_Blume1)\
**Post date:** [October 25, 2019, 7:30am UTC](https://community.sonarsource.com/t/problem-with-c-project-analysis/15880/5 "2019-10-25T07:30:22Z")

</div>

Hi, i has to add the /d:sonar.verbose=true to the begin call, but now i got the following debug output:  
[log.txt](https://community.sonarsource.com/uploads/short-url/vLQQ3TLvnkfE1l31a9NIopd94Gg.txt) (50.5 KB)

---

<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:** [October 25, 2019, 7:38am UTC](https://community.sonarsource.com/t/problem-with-c-project-analysis/15880/6 "2019-10-25T07:38:03Z")

</div>

Thank you !

So, as far as i can see, no source are detected, and only 2 files are categorized as tests :

1D1FE4FD-F1EB-48C2-A33C-2D32F1BE631B.sonar.tests=  
“/app/FizzbuzzImpl/Fizzbuzz.cs”,  
“/app/FizzbuzzImpl/FizzbuzzTest.cs”

Do you have any other source file in your project / solution ?

Otherwise, if you want the scanner to not detect those files as test, you can add the following property group in your csproj :

```auto
<PropertyGroup>
	<!-- Mark the project as being a test project -->
	<SonarQubeTestProject>false</SonarQubeTestProject>
</PropertyGroup>

```

---

<div class="post-metadata">

**Author:** ![Jakob\_Blume1](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/jakob_blume1/32/7215_2.png) [@Jakob\_Blume1](https://community.sonarsource.com/u/Jakob_Blume1)\
**Post date:** [October 25, 2019, 8:12am UTC](https://community.sonarsource.com/t/problem-with-c-project-analysis/15880/7 "2019-10-25T08:12:42Z")

</div>

Thank you, that was the fix!! 🙂 I was searching in the right direction, but does not know about the PropertyGroup setting. One further question: _ **Is there a way to disable the Check for TestProject in the CLI call and not with editing the project settings?** _

---

<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:** [October 25, 2019, 8:35am UTC](https://community.sonarsource.com/t/problem-with-c-project-analysis/15880/8 "2019-10-25T08:35:37Z")

</div>

In fact this check and more globally the target that is executed is lead by the Scanner for MSBuild itself, and here are the rules :

- Projects whose full project file name matches the regular expression specified in  
the analysis setting “sonar.msbuild.testProjectPattern” will be treated as test  
projects. This setting is set via the SonarQube portal (set “Test project pattern”  
in the per-project settings on the MSBuild tab for the C# plug-in).  
By deault, any projects with “test” (case-insensitive) in the project name will  
be treated as test projects.  
Note that the regular expression uses the .Net Regex format i.e. “+” is the  
single character wildcard and “\*” is the multi-character wildcard (zero to many).
- MSTest projects will be treated as test projects.  
The $(ProjectTypeGuids) property of MS Test projects contains a specific guid  
(“3AC096D0-A1C2-E12C-1390-A8335801FDAB”)

There’s no way to disable this check specifically for the moment.

Mickaël

---

<div class="post-metadata">

**Author:** ![Jakob\_Blume1](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/jakob_blume1/32/7215_2.png) [@Jakob\_Blume1](https://community.sonarsource.com/u/Jakob_Blume1)\
**Post date:** [October 25, 2019, 8:42am UTC](https://community.sonarsource.com/t/problem-with-c-project-analysis/15880/9 "2019-10-25T08:42:02Z")

</div>

Thank you for the information and your help!

---

<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:** [October 25, 2019, 8:47am UTC](https://community.sonarsource.com/t/problem-with-c-project-analysis/15880/10 "2019-10-25T08:47:38Z")

</div>

And one other tip : i think that the best practice would be to separate your source code and unit tests in separate projects (one with the UT will be categorized as Test project, and the other one will be analyzed), so it should be easier for you to manage.

---

<div class="post-metadata">

**Author:** ![Jakob\_Blume1](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/jakob_blume1/32/7215_2.png) [@Jakob\_Blume1](https://community.sonarsource.com/u/Jakob_Blume1)\
**Post date:** [October 25, 2019, 8:51am UTC](https://community.sonarsource.com/t/problem-with-c-project-analysis/15880/11 "2019-10-25T08:51:48Z")

</div>

Yeah, you are right 👍
