I was executing "msbuildsonarrunner" commands ( begin, msbuild , end ) from normal command prompt. Normal command prompt is configured with MsBuild path ( i.e. C:\Program Files (x86)\MSBuild\12.0\Bin). When I fire MsBuild command, Build is happening with No Fxcop Analysis. Then I checked same with Visual studio developer command prompt. Yes, Fxcop analysis is happening. I checked further to know how Visual studio command prompt is configured. In properties of VS Developer command prompt, I see Target as [ "%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\VsDevCmd.bat"" ].
Then I switch back to normal command prompt and fired following command.
CALL "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\VsDevCmd.bat". Then it started behaving as VS developer command prompt ( but obvious). It started Fxcop analysis when I fired MsBuild Command.
MsBuild command log of my dummy project is given below. I have included CA1823 fxcop rule in my quality profile. You can see warning in build log ( bold one) as I intentionally violated it.
Microsoft (R) Build Engine version 12.0.21005.1
[Microsoft .NET Framework, version 4.0.30319.34209]
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 10/13/2015 12:20:14 PM.
Project "D:\SonarQubeProjects\Fibanocci\Fibanocci\Fibanocci.csproj" on node 1 (default targets).
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.
_CopyAppConfigFile:
Skipping target "_CopyAppConfigFile" because all output files are up-to-date with respect to the input files.
CopyFilesToOutputDirectory:
Fibanocci -> D:\SonarQubeProjects\Fibanocci\Fibanocci\bin\Debug\Fibanocci.exe
OverrideCodeAnalysisProperties:
Running FxCop analysis using the SonarQube ruleset. Ruleset: D:\SonarQubeProjects\Fibanocci\Fibanocci.sonarqube\conf\SonarQubeFxCop-cs.ruleset
RunCodeAnalysis:
Running Code Analysis...
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\FxCop\FxCopCmd.exe /outputCulture:1033 /out:"bin\Debug\Fibanocci.exe.CodeAnalysisLog.xml" /file:"bin\Debug\Fibanocci.exe" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.1\Microsoft.CSharp.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.1\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.1\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.1\System.Data.DataSetExtensions.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.1\System.Data.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.1\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.1\System.Xml.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.1\System.Xml.Linq.dll" /directory:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.1" /ruleSet:"=D:\SonarQubeProjects\Fibanocci\Fibanocci.sonarqube\conf\SonarQubeFxCop-cs.ruleset" /rulesetdirectory:"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\Rule Sets" /rule:"-C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\FxCop\Rules" /searchgac /ignoreinvalidtargets /forceoutput /successfile /ignoregeneratedcode /saveMessagesToReport:Active /timeout:120
MSBUILD : warning CA1823: Microsoft.Performance : It appears that field 'Program.obj' is never used or is only ever assigned to. Use this field or remove it. [D:\SonarQubeProjects\Fibanocci\Fibanocci\Fibanocci.csproj]
Code Analysis Complete -- 0 error(s), 1 warning(s)
SetStyleCopAnalysisSettings:
Setting 'sonar.stylecop.projectFilePath' to 'D:\SonarQubeProjects\Fibanocci\Fibanocci\Fibanocci.csproj'
WriteSonarQubeProjectData:
Directory "D:\SonarQubeProjects\Fibanocci\Fibanocci.sonarqube\out\Fibanocci__AnyCPU_Debug_635803356164104589" doesn't exist. Skipping.
Creating directory "D:\SonarQubeProjects\Fibanocci\Fibanocci.sonarqube\out\Fibanocci__AnyCPU_Debug_635803356164104589".
Done Building Project "D:\SonarQubeProjects\Fibanocci\Fibanocci\Fibanocci.csproj" (default targets).
Build succeeded.
"D:\SonarQubeProjects\Fibanocci\Fibanocci\Fibanocci.csproj" (default target) (1) ->
(RunCodeAnalysis target) ->
MSBUILD : warning CA1823: Microsoft.Performance : It appears that field 'Program.obj' is never used or is only ever assigned to. Use this field or remove it. [D:\SonarQubeProjects\Fibanocci\Fibanocci\Fibanocci.csproj]
1 Warning(s)
0 Error(s)
Time Elapsed 00:00:01.82
It worked !!! but landed me in another problem. These issues are not getting posted to Sonar server. DashBoard is showing 0 issues, though I see Fxcop warnings in analysis results.