3
votes

I'm building and analyzing a sample C# project on a build server with the following configuration:

  • Jenkins 1.630;
  • SonarQube 5.3 with all the updates;
  • FxCop 10.0

I put the following steps in Jenkins Job:

  • SonarQube Scanner for MSBuild - Begin Analysis
  • Build a Visual Studio project or solution using MSBuild (MSBuild 14)
  • SonarQube Scanner for MSBuild - End Analysis

If in the default C# Profile are no FxCop rules, everything works fine: the project is compled without warnings then analyzed. If there is at least one FxCop, the build fails:

V:\JenkinsWkFolder\Test\.sonarqube\bin\targets\SonarQube.Integration.targets(402,5): 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. [V:\JenkinsWkFolder\Test\CSharpConsoleApp\CSharpConsoleApp.csproj]

Done Building Project "V:\JenkinsWkFolder\Test\CSharpConsoleApp\CSharpConsoleApp.csproj" (Rebuild target(s)) -- FAILED.
Done Building Project "V:\JenkinsWkFolder\Test\CITest.sln" (rebuild target(s)) -- FAILED.

Build FAILED.

"V:\JenkinsWkFolder\Test\CITest.sln" (rebuild target) (1) ->
"V:\JenkinsWkFolder\Test\CSharpConsoleApp\CSharpConsoleApp.csproj" (Rebuild target) (2) ->
(FailIfFxCopNotInstalled target) -> 
  V:\JenkinsWkFolder\Test\.sonarqube\bin\targets\SonarQube.Integration.targets(402,5): 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. [V:\JenkinsWkFolder\Test\CSharpConsoleApp\CSharpConsoleApp.csproj]

    0 Warning(s)
    1 Error(s)

FxCop is installed on the build server, while Visual Studio is not. Where does MsBuildSonarRunner looks for the FxCop executable?

I don't know if you need some other info, please feel free to ask more details. Thanks in advance. Best Regards,

Mario.

1
is FXcop in the path?Sam Holder
Thank you for the reply, @sam-holder. I set the FxCop path in the step Build Environment / Inject environment variables to the build process Properties Content: PATH=C:\Program Files (x86)\Microsoft Fxcop 10.0;C:\.... Is there any deeper debug option other than Additional arguments: /d:sonar.verbose=true in SonarQube Scanner for MSBuild - Begin Analysis?Mario
I ran msbuild from command line, having the same error. Executing it at the maximum verbosity (diagnostic), there is a suspect error: Target "SetFxCopAnalysisResult" skipped, due to false condition; ( $(SonarQubeRunMSCodeAnalysis) == 'true' ) was evaluated as ( == 'true' ) The problem, seems to me, is an error coming from msbuild ruleset that have nothing to do with fxcop installation..Mario

1 Answers

2
votes

SonarQube only supports MSBuild 14 along with FxCop 14 (MSBuild 12/FxCop 12 will be deprecated soon).

Unfortunately, when installing MSBuild Tools separately from VisualStudio, FxCop is not installed with MSBuild. To get FxCop 14 you must install Visual Studio 2015 (FxCop 10 was the last version that could be installed standalone). On the internet you can find ways to manually install FxCop 14 without VS2015 but this is not a Microsoft official procedure.