I encounter a really weird behaviour with fxcopcmd.exe. If I launch the fxcopcmd.exe specifying only one assembly (Assembly X), there is no violations. But if I specify all the assemblies of the solution, it throws a lot of violation in (Assembly X). Is there something that I missed? Note that when using code analysis in visual studio, there is no violations even if I Run the Code Analysis for all the assemblies.
More details:
1- We use a solution in Visual Studio 2013 with six huge C# projects.
2- We use fxcopcmd.exe that comes from the installation of VisualStudio 2013 (Version 12.0.21005.1).
3- Example of command line command that do not detect any violation:
tools\FxCopCmd\FxCopCmd.exe /file:build\bin\Assembly1.dll /out:results.txt /ruleset:=Tools\FxCopRuleSet\CompagnyRules.ruleset /ignoregeneratedcode
4- Example of command line command that detects violations:
tools\FxCopCmd\FxCopCmd.exe /file:build\bin\Assembly1.dll /file:build\bin\Assembly2.dll /file:build\bin\Assembly3.dll /file:build\bin\Assembly4.dll /out:results.txt /ruleset:=Tools\FxCopRuleSet\CompagnyRules.ruleset /ignoregeneratedcode
Note that more than 100 violations in Assembly1.dll are detected.
The rules that cause violations are:
AvoidUninstantiatedInternalClasses
, AvoidUncalledPrivateCode
, AvoidUnusedPrivateFields
,
TypeNamesShouldNotMatchNamespaces
So this is not related to relations between different assemblies. The only solution I found to automate it in TeamCity properly is to use a nant script that calls fxcopcmd.exe on the different assemblies one by one and output the results in different files.
Any ideas are welcome!
Thanks.