在Debug构建期间禁用SonarLint分析

Nar*_*ana 4 c# sonarlint sonarlint-vs

是否可以(在Visual Studio中使用SonarLint扩展)在Debug构建期间禁用Sonar分析器,但是在Release版本中是否启用它们?原因是将解决方案连接到SonarQube大大增加了构建时间.

Nar*_*ana 5

如果我在调试配置中从Visual Studio中构建解决方案,我最终修改了.csproj文件以删除分析器.这样,sonarlint不会抱怨规则已经过时,也不会受到更新的影响.我从这里得到了答案

<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>
Run Code Online (Sandbox Code Playgroud)