小编Mar*_*ies的帖子

SonarQube MSBuild扫描仪不会从分析中排除文件

我们目前正在使用SonarQube Scanner for VSTS/TFS 4.1.1(使用SonarQube Scanner 4.1.1).

我们想做什么:

对于我们解决方案中的某些项目(模块),我们希望从分析和代码覆盖率统计信息中排除文件.这应该通过使用文件模式而不是修改TFS构建任务以可维护的方式完成.

项目结构:

    |- Source
      |- ProjectA
        |- Scripts (should be excluded)
        |- OwnCode
      |- ProjectB
        |- Views (only code coverage should be excluded)
        |- Presenters
        |- ...
      |- ProjectC
        |- Scripts (should be scanned)
        |- ...
      |- ...
      |- Solution.sln
Run Code Online (Sandbox Code Playgroud)

我们尝试了什么:

  1. 排除在TFS构建任务中
    • 绝对路径(带反斜杠或斜杠):( sonar.exclusions="$(Build.SourcesDirectory)\Source\ProjectA\Scripts\**\*.js"类似于覆盖范围)
    • 相对路径: **/ProjectsA/Scripts/**/*.js
  2. 不包括在SonarQube前端
    • 分析排除: **/ProjectA/Scripts/**/*.js
    • 覆盖范围排除: **/ProjectB/Views/**/*.cs
  3. 不包括sonar-project.properties:
    • 不受支持并导致以下错误: sonar-project.properties files are not understood by the SonarScanner for MSBuild

我们看到了什么:

SonarQube Web界面中的扫描程序上下文的日志是:

  Settings for module: Solution:Solution:6FA7B5C2-667D-4387-98B9-445617F2AC0B
  - …
Run Code Online (Sandbox Code Playgroud)

.net msbuild tfs sonarqube sonarqube-scan

9
推荐指数
1
解决办法
3319
查看次数

标签 统计

.net ×1

msbuild ×1

sonarqube ×1

sonarqube-scan ×1

tfs ×1