I have created dotnet roslyn analyzer which run on compilation.
[System.Diagnostics.CodeAnalysis.SuppressMessage("MicrosoftCodeAnalysisCorrectness", "RS1026:Enable concurrent execution", Justification = "<Pending>")]
public override void Initialize(AnalysisContext context)
{
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.ReportDiagnostics);
context.RegisterCompilationAction(AnalyzeCompilation);
}
I added it as a package to one of our projects, it didn't run. I figured that i need to allow Entire Solution Analysis in VS2022. Tools => Options => Text Editor => c# => Analysis => Entire Solution
Visual Studio Entire Solution Analysis feature
After i allowed it, my analyzer working correctly.
I also want it to run in our pipeline, but the analyzer not running on dotnet build . I am not sure if it's related to Entire Solution which i allowed in VS2022 or not. we have other analyzer which running correctly on dotnet build. this is how our Directory.BUild.props file looks.
<Project>
<PropertyGroup>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="16.10.56">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
and Microsoft.VisualStudio.Threading.Analyzers working on dotnet build. How can i enable my Analyzer which run on ComplilationAction to work on dotnet build like it working in VS2022?