How to make Sonarqube exclude a .NET (C#) project from coverage measures

前端 未结 6 1166
Happy的楠姐
Happy的楠姐 2021-02-05 14:07

Sonarqube allows for individual files to be excluded from code coverage by adding patterns in the sonar.coverage.exclusions key. This can be done on a project level by

6条回答
  •  日久生厌
    2021-02-05 14:59

    I had the same problem, and it took me a while to figure it out:

    Set up a Directory.Build.props file in the solution directory with this content:

    
    
      
      
    
          true
          true
    
      
    
      
      
    
        
        
        
    
        
    
        
    
      
    
    
    

    This fragment will be included in all project files as explained here https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build

    Set the regex in the environment variable SQExclusionFilter accordingly. Use double-backslashes for path separation. In windows shell escape pipe characters with a caret: e.g.

    set SQExclusionFilter=(path1\\project)^|(path2\\project)
    

    Credits to Duncan Pocklington from SQ/MS!

    • https://jira.sonarsource.com/browse/SONARMSBRU-191?focusedCommentId=155587&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-155587

提交回复
热议问题