【问题标题】:Analyzing C# VS Solution using SonarQube, MSBuild14 and FxCop10使用 SonarQube、MSBuild14 和 FxCop10 分析 C# VS 解决方案
【发布时间】:2016-12-18 03:22:51
【问题描述】:

我所在的团队目前使用 VS2013,所以我的安装是 MSBuild12。 我安装了FXCop10。 我安装了MSBuild14。 我安装了SonarQube Scanner for MSBuild 2.1

我在演示模式下运行 SonarQube 5.6 版。 我启用了所有规则,并且可以使用以下批处理脚本进行分析:

<!-- language: lang-sh-->
@echo off
REM Set FxCop10Directory="C:\Program Files (x86)\Microsoft Fxcop 10.0\"
REM Set FxCop10="C:\Program Files (x86)\Microsoft Fxcop 10.0\FxCopCmd.exe"

Set ScannerDirectory="D:\Programs\sonar-scanner-2.6.1\bin\"
Set MSBuild12="C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe"
Set MSBuild14="C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe"
Set Runner="MSBuild.SonarQube.Runner.exe"
Set Key="DEMO2016"
Set Name="SonarQube Internal Demo"
Set Version="0.0.0.0"

PATH=%PATH%;%ScannerDirectory%

call %Runner% begin /k:%Key% /n:%Name% /v:%Version%
call %MSBuild14% /t:Rebuild
call %Runner% end
pause

当我尝试通过将调用更改为调用 %MSBuild14% /t:Rebuild 来升级到 MSBuild14 时,我收到一个错误。

error : FxCop must be installed when some of its rules are enabled in the SonarQube quality profile. FxCop is included as part of Visual Studio.

VS2013 附带另一个版本的 FXCop。

如何控制MSBuild.SonarQube.Runner 使用的版本? 如何为MSBuild.SonarQube.Runner 设置 FxCop10?

【问题讨论】:

    标签: c# msbuild sonarqube fxcop


    【解决方案1】:

    我不知道为什么 MSBuild12 最初对我有用。 我必须导入开发环境才能在我的系统上运行。

    <!-- language: none-->
    
    @echo off
    echo.
    echo Setup References
    Set ScannerDirectory="D:\Programs\sonar-scanner-2.6.1\bin\"
    Set MSBuild14="C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe"
    Set Runner="MSBuild.SonarQube.Runner.exe"
    Set vcvars="C:\LegacyApp\VisualStudio2013\VC\vcvarsall.bat"
    echo.
    echo Setup Runner Parameters
    Set Key="DEMO2016"
    Set Name="SonarQube Internal Demo"
    Set Version="0.0.0.0"
    echo.
    echo Create Environment
    PATH=%PATH%;%ScannerDirectory%
    call %vcvars%
    echo.
    echo Runner Begin
    call %Runner% begin /k:%Key% /n:%Name% /v:%Version%
    echo.
    echo MSBuild Rebuild
    call %MSBuild14% /t:Rebuild
    echo.
    echo Runner End
    call %Runner% end
    pause
    

    输出显示当前使用的 FxCop 版本在哪里:

    <!-- language: none-->
    
    Running Code Analysis...
    C:\LegacyApp\VisualStudio2013\Team Tools\Static Analysis Tools\FxCop\FxCopCmd.exe 
    

    在命令提示符下执行该文件会返回其版本。

    【讨论】:

      猜你喜欢
      • 2018-06-07
      • 1970-01-01
      • 2021-09-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-31
      • 1970-01-01
      相关资源
      最近更新 更多