SonarLint editing csproj files even with Directory.Build.Props file present

Hello we are using Visual Studio 2022 and SonarQube with Developer edition 9.5.0.56709. We are trying to use SonarLint connected edition and after looking at community posts in this forums as well as using the following sample as guide:

We have also checked in this Directory.Build.Props and the .sonarlint folder into GitHub but everytime I open Visual Studio SonarLint output windows says that there are unbound project and then goes ahead to edit csproj files with following entry:

It doesnt create local rulesets for every project which it was doing before having the Directory.Build.props file so I know the props file is working but not sure if I missed some settings or configuration to avoid the SonarLint.xml entry in all the csproj files. Please find the Directory.Build.Props content below:

<Project>

  <PropertyGroup>
    <CodeAnalysisRuleSet>$(MSBuildThisFileDirectory).sonarlint\******csharp.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
  
  <ItemGroup>
    <AdditionalFiles Include="$(MSBuildThisFileDirectory).sonarlint\*****\CSharp\SonarLint.xml">
      <Link>Properties\SonarLint.xml</Link>
    </AdditionalFiles>
  </ItemGroup>
</Project>

I have removed the folder name which contains the sonarlint.xml file.
I have tried with and without Itemgroup entry present in the props file, I don’t get any different result. Also my solution file, Directory.Build.Props file and .sonarlint folder are in same folder.

Thanks for any help if possible.

Hi,

You’re trying to set up connected mode by adding a file to your project/solution? Can you remove the file and try setting it up via the UI instead?

 
Ann

Hello, no I do the connection using UI only:
image

If I remove the Directory.Build.Props, SonarLint starts creating local rulesets for all projects as well the mentioned xml entries.

1 Like