1

I currently have 25+ repositories to maintain. For all these repositories I would like to add Code Analysis using Roslyn analyzers.

Because I want to have to control over the analyzers that are being used from one central location. My idea was to create a NuGet package which is referencing all the analyzers that I need. However, this seems not to be working.

My NuGet package now looks like this:

  <ItemGroup>
    <PackageReference Include="SonarAnalyzer.CSharp" Version="8.3.0.14607">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>

And the nuget package is referenced like this:

<PackageReference Include="NuGet.Package" Version="1.0.0" />

The analyzer SonarQube.CSharp doesn't appear in the list of analyzers in the parent project.

Should this work? And how should I change it to make this work?

Richard Mosselveld
  • 702
  • 1
  • 6
  • 21

1 Answers1

1

I seem to have found the solution. Adding the packagereference in the .props file of the NuGet package will get the analyzer to work.

Richard Mosselveld
  • 702
  • 1
  • 6
  • 21