Sonar Lint does not work when solution is open but work when single project is opened

  • Operating system: Windows 11
  • SonarLint plugin version: 8.4.0.73538
  • Jetbrains Rider version: 2023.1.3
  • Programming language you’re coding in: C#
  • Is connected mode used: No (AFAIK)

And a thorough description of the problem / question:
Our project has following folder structure

├── build
    ├── x.sln
└── src
    ├── a/a.csproj
    ├── a.SpecFlowTests/a.SpecFlowTests.csproj
    ├── a.Fullflow.SpecFlowTests/a.Fullflow.SpecFlowTests.csproj
    ├── a.IntegrationTests/a.IntegrationTests.csproj
    ├── a.TestsUtils/a.TestsUtils.csproj
    ├── aTests/aTest.csproj
    └── RabbitMQ

11 directories

When I open the x.sln SonarLint does not show any errors - nothing. empty. instant inspection without any message.

When I open for eg. just a.csproj SonarLint works perfectly.

image


What I have tried:

  • Reinstalling Sonarlint
  • Reinstalling Rider
  • Invalidate Caches
  • Opening in Visual Studio with SonarLint

How can I fix it?
Why this is happening?

Sonarlint run when I open just a.csproj

Hello @Tymisko,

I suspect it was due to the Solution file being in a subfolder but I was not able to reproduce your problem. Could you please enable verbose logs and share them with us?

Hello. Thanks for your getting involved. I thought my post would be abandoned.

Analysing 'Program.cs'...
Starting analysis with configuration:
[
  baseDir: C:\Users\USER\repo\XYZ\backend\build
  extraProperties: {sonar.cs.internal.solutionPath=C:\Users\USER\repo\XYZ\backend\build\a.sln, sonar.cs.internal.dotnetCliExeLocation=C:\Program Files\dotnet\dotnet.exe, sonar.cs.internal.msBuildPath=C:\Program Files\dotnet\sdk\7.0.102}
  moduleKey: Module: 'rider.module'
  excludedRules: []
  includedRules: []
  ruleParameters: {}
  inputFiles: [
    file:///C:/Users/USER/repo/XYZ/backend/src/a/Program.cs (UTF-8)
  ]
]

Start analysis
Index files
1 file indexed
Added 186 checks for language='ts', repository='typescript'
Added 184 checks for language='js', repository='javascript'
'OmniSharp' skipped because there is no related files in the current project
Execute Sensor: HTML
Execute Sensor: TextAndSecretsSensor
1 source file to be analyzed
1/1 source file has been analyzed
'JavaScript/TypeScript analysis' skipped because there is no related files in the current project
'JavaScript inside YAML analysis' skipped because there is no related files in the current project
'JavaScript inside HTML analysis' skipped because there is no related files in the current project
Execute Sensor: CSS Rules
No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
Done in 155ms

Processed 0 issues
Found 0 issues and 0 hotspots

Entire logs: sonarlint-logs.txt (38.6 KB)

Hi @Tymisko,

We found the origin of the problem, it’s a regression we introduced in version 8.3 when the solution file is not in the root folder. I created this ticket to fix the problem, I am not sure we have the bandwidth to fix that immediately. You can always revert to the 8.2 via the Marketplace and offline installation while waiting for the fix. The other option would be to put your solution file in the root folder.

Thanks for raising this and sorry for the inconvenience

Thank you

Almost a year ago the issue was reported and nothing was done toward this.
Could you make this a priority to make sure the location of the solution doesn’t have an impact on the Sonarlint plugin?

I need to stay with the 8.2 version in order to make it work when the newest Sonarlint plugin is 10.6.2.78685 :frowning:

At the moment our folder structure has changed:

├── x.sln
└── src
  ├── a/a.csproj
  ├── a.SpecFlowTests/a.SpecFlowTests.csproj
  ├── a.Fullflow.SpecFlowTests/a.Fullflow.SpecFlowTests.csproj
  ├── a.IntegrationTests/a.IntegrationTests.csproj
  ├── a.TestsUtils/a.TestsUtils.csproj
  ├── aTests/aTest.csproj
  └── RabbitMQ

And This is still not working.

Hello @Tymisko, sorry for the lack of progress on this one.

We are currently refactoring a few SonarLint parts, and I would like to tackle this issue simultaneously. I tried reproducing a similar folder structure as you mentioned, and it’s working on my custom build.

To make sure I’m not missing something, could you please send us a reproducible example (via a git project, for example) so I can assess with certainty that the fix is working? Thank you.