I am currently working on a solution with multiple projects in it, and when I try to run the code analysis tool from VS12 I get the following error when trying to run it:
CA0058 Error Running Code Analysis CA0058 : The referenced assembly "Microsoft.Practices.Unity, Version=2.1.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" could not be found. This assembly is required for analysis and was referenced by: C:\MyProject\bin\Release\MyProject.exe, C:\MyProject\packages\Prism.UnityExtensions.18.104.22.168\lib\NET40\Microsoft.Practices.Prism.UnityExtensions.dll. [Errors and Warnings] (Global)
CA0052: No targets were selected
CA0055 Error Running Code Analysis CA0055 : C:\MyProject\bin\Release\IntraEUA Management Software 2.0.exe The following error was encountered while reading module "Microsoft.Practices.Prism.UnityExtensions": Assembly reference cannot be resolved: Microsoft.Practices.Unity, Version=2.1.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35. [Errors and Warnings] (Global)
The underlying issue is due to the combination of two facts:
2.1.505.0, with a strong name, but you have a newer version, strongly signed with version
Meaning that, this mess is not your fault, simply the result of attempting to use an "unexpected" combination of library versions, and of an oversight in FxCop's assembly resolution logic.
The main way to get past that issue is to set FxCop's
StrongNameIgnoringVersion. There are ways to achieve that, one on a per-machine setting, and the other on a per-project setting.
FxCopCmd.exe.config(from VS12 invocation) or
FxCop.exe.config(command-line call to
.csprojfile, inside of a
<PropertyGroup> <CodeAnalysisAdditionalOptions>/assemblyCompareMode:StrongNameIgnoringVersion</CodeAnalysisAdditionalOptions> </PropertyGroup>
I would recommend using the per-project setting for any project that you intend to share with other people.