.Net project analysed as a test project. but project is not a test project

Hi there,

Since recently we facing some issues when using sonarCube (C# .net project)

  • SonarScanner Form MSBuild 4.6.0
  • MSBuild 15.0
  • SonarC# 7.11.0.8083

in any previous version of the sonarScanner everything went fine. but since using version 4.6.0 some project are analysed as a test project, so no issues are reported. but these projects are not test projects.
The ProjectInfo.Log contains:

Product project
---------------------------------------
D:\GRAY-Agent-2\_work\17\s\xxProjectName\xxProjectName.Common\xxProjectName.Common.csproj
D:\GRAY-Agent-2\_work\17\s\xxProjectName\xxProjectName.ControlCenter\xxProjectName.ControlCenter.csproj
D:\GRAY-Agent-2\_work\17\s\xxProjectName\Autocad\xxProjectName.AddIn.AutoCAD.Core\xxProjectName.AddIn.AutoCAD.Core.csproj
D:\GRAY-Agent-2\_work\17\s\xxProjectName\Autocad\xxProjectName.AddIn.AutoCAD.2015\xxProjectName.AddIn.AutoCAD.2015.csproj
D:\GRAY-Agent-2\_work\17\s\xxProjectName\xxProjectName.Connector.ArticleManager\xxProjectName.Connector.ArticleManager.csproj
D:\GRAY-Agent-2\_work\17\s\xxProjectName\Autocad\xxProjectName.AddIn.AutoCAD.2017\xxProjectName.AddIn.AutoCAD.2017.csproj
D:\GRAY-Agent-2\_work\17\s\xxProjectName\Autocad\xxProjectName.AddIn.AutoCAD.2018\xxProjectName.AddIn.AutoCAD.2018.csproj
D:\GRAY-Agent-2\_work\17\s\xxProjectName\Autocad\xxProjectName.AddIn.AutoCAD.2019\xxProjectName.AddIn.AutoCAD.2019.csproj
D:\GRAY-Agent-2\_work\17\s\xxProjectName\xxProjectName.Common.UI\xxProjectName.Common.UI.csproj


Test projects
---------------------------------------
D:\GRAY-Agent-2\_work\17\s\xxProjectName\xxProjectName.Utils\xxProjectName.Utils.csproj
D:\GRAY-Agent-2\_work\17\s\xxProjectName\xxProjectName.Tests\xxProjectName.Tests.csproj
D:\GRAY-Agent-2\_work\17\s\xxProjectName\xxProjectName.Api.Tests\xxProjectName.Api.Tests.csproj
D:\GRAY-Agent-2\_work\17\s\xxProjectName\xxProjectName.BusinessLayer.Tests\xxProjectName.BusinessLayer.Tests.csproj
D:\GRAY-Agent-2\_work\17\s\xxProjectName\xxProjectName.Common.Tests\xxProjectName.Common.Tests.csproj
D:\GRAY-Agent-2\_work\17\s\xxProjectName\xxProjectName.ControlCenter.Tests\xxProjectName.ControlCenter.Tests.csproj
D:\GRAY-Agent-2\_work\17\s\xxProjectName\xxProjectName.ControlCenter.BusinessLayer.Tests\xxProjectName.ControlCenter.BusinessLayer.Tests.csproj
D:\GRAY-Agent-2\_work\17\s\xxProjectName\xxProjectName.Utils.Tests\xxProjectName.Utils.Tests.csproj
D:\GRAY-Agent-2\_work\17\s\xxProjectName\xxProjectName.BusinessLayer\xxProjectName.BusinessLayer.csproj
D:\GRAY-Agent-2\_work\17\s\xxProjectName\xxProjectName.Connector.ArticleManager.Tests\xxProjectName.Connector.ArticleManager.Tests.csproj
D:\GRAY-Agent-2\_work\17\s\xxProjectName\xxProjectName\xxProjectName.csproj
D:\GRAY-Agent-2\_work\17\s\xxProjectName\xxProjectName.ControlCenter.BusinessLayer\xxProjectName.ControlCenter.BusinessLayer.csproj
D:\GRAY-Agent-2\_work\17\s\xxProjectName\xxProjectName.Api\xxProjectName.Api.csproj
D:\GRAY-Agent-2\_work\17\s\xxProjectName\xxProjectName.TestUtilities\xxProjectName.TestUtilities.csproj


Invalid projects
---------------------------------------
{none}


Skipped projects
---------------------------------------
{none}


Excluded projects
---------------------------------------
{none}

for example:
D:\GRAY-Agent-2_work\17\s\xxProjectName\xxProjectName\xxProjectName.csproj
Does not have any test in it, but is analyses as a test project.

I have tried to set the sonar.msbuild.testProjectPattern=".*Tests?.(cs|vb)proj$", but this did not help.

Any ideas how to resolve this.

We had the same problem, and had to manually set a flag in the .csproj file.

It did the trick, although it is still unclear why it used to work without changing the project fils,

But thank you for the answer!

There was a change in the heuristics engine that causes projects to be misidentified as test projects in the last update.