簡體   English   中英

使用SonarQube,MSBuild14和FxCop10分析C#VS解決方案

[英]Analyzing C# VS Solution using SonarQube, MSBuild14 and FxCop10

我所在的團隊當前使用VS2013,因此我的安裝是MSBuild12。 我安裝了FXCop10 我安裝了MSBuild14 為MSBuild 2.1安裝了SonarQube Scanner

我在演示模式下運行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使用的Version? 如何為MSBuild.SonarQube.Runner設置FxCop10?

我不知道為什么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 

在命令提示符下執行該文件將返回其版本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM