Search code examples
c#visual-studiovisual-studio-2019roslyn-code-analysis

Run Roslyn analyzers during live code editing but not during build


The Roslyn code analyzers work both in live code editing and at build time.

However, they slow down the build quite a bit. Therefore, I'd like to disable them during build time - but still use them during live editing.

Is that possible?


Solution

  • You can use RunAnalyzersDuringBuild in the .csproj:

    <PropertyGroup>    
         <TargetFramework>netcoreapp3.1</TargetFramework> 
         <RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>  
    </PropertyGroup>
    

    Update: Some documentation from the comments Docs