I'm using SonarLint for a dotnetcore 2 project, this project also target net461. Each warning gets reported for each targetframework, resulting in duplicate warnings.
I tried to fix this by adding a condition to the analyzer package ref, this didn't work:
<PackageReference Include="SonarAnalyzer.CSharp" Version="6.7.1.4347" Condition="'$(TargetFramework)'=='netcoreapp2.0'">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Is there any way to setup sonarlint for 1 targetframework only?
This looks indeed a bit weird but this is the default behavior of roslyn-based analyzers. From my tests the behavior is conform with the one produced by StyleCope.Analyzers
, Roslynator
, CodeCracker
and so on.
I haven't found any ticket on Roslyn repository regarding a change of this behavior.