I created a custom NuGet package containing a packagereference to an analyzer assembly using a targets file:
<Project>
<ItemGroup>
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.3.0.14607">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
If I include this package in my solution and build, I see the analyzer warnings.
However, if i run dotnet build, it doesn't give any analyzer warnings.
If I include the analyzer package directly in my project, I get the warnings both in Visual Studio and command line.
What is the difference between a visual studio build and a dotnet build? I tried the UseCodeAnalysis=true parameter, but this doesn't work. Is there any other property I should set?