Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable SonarLint analysis during Debug build

Is it possible (in Visual Studio using SonarLint extension) to disable Sonar Analyzers during Debug build, but keep them enabled in Release build? The reason is that connecting the solution to SonarQube has drastically increased the build time.

like image 812
Narayana Avatar asked Nov 16 '17 09:11

Narayana


People also ask

How do I turn off SonarLint?

Just go to the project preferences and choose SonarLint. Then uncheck “Run SonarLint” automatically.

How do I turn off SonarLint automatic analysis in Intellij?

Save this answer. Show activity on this post. In Android Studio 3.5. 2: Go to File -> Settings -> Tools -> SonarLint -> Settings(Tab) then uncheck the Automatically trigger analysis check box.

How do I turn off code analysis?

To open this page, right-click the project node in Solution Explorer and select Properties. Select the Code Analysis tab. To disable source analysis at build time, uncheck the Run on build option. To disable live source analysis, uncheck the Run on live analysis option.

How do I know if SonarLint is installed in Visual Studio?

Adding SonarLint to Visual Studio Then in the search box, search for “SonarLint”. Once you see SonarLint, press “Download”. You must now sign out of Visual Studio to let the changes save properly. VSIX Installer will prompt you to allow for it to modify Visual Studio.


1 Answers

I ended up modifying the .csproj files to remove the analyzers if I'm building the solution from within Visual Studio in Debug configuration. That way, sonarlint does not complain that rules are outdated, nor does it get affected by updates. I got the answer from here

<Target Name="DisableAnalyzersForVisualStudioBuild"
        BeforeTargets="CoreCompile"
        Condition="'$(BuildingInsideVisualStudio)' == 'True' And '$(BuildingProject)' == 'True' And '$(Configuration)' == 'Debug'">
  <!--
    Disable analyzers when building a project inside Visual Studio. Note that analyzer behavior for IntelliSense purposes is not altered by this.
  -->
  <ItemGroup>
    <Analyzer Remove="@(Analyzer)"/>
  </ItemGroup>
</Target>
like image 193
Narayana Avatar answered Oct 05 '22 22:10

Narayana