Assembly Binding Redirection and Code Analysis

亡梦爱人 提交于 2019-12-02 17:25:48

Just to supplement with a little more precise answer:

You need to either run FxCopCmd.exe with:

fxcopcmd.exe /assemblyCompareMode:StrongNameIgnoringVersion

or modify your Visual Studio project file for each build configuration's property group, like this:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
  ...
  <CodeAnalysisAdditionalOptions>/assemblyCompareMode:StrongNameIgnoringVersion</CodeAnalysisAdditionalOptions>
</PropertyGroup>

See http://davesbox.com/archive/2008/06/10/reference-resolution-changes-in-code-analysis-and-fxcop-part-1.aspx and http://davesbox.com/archive/2008/06/14/reference-resolutions-changes-in-code-analysis-and-fxcop-part-2.aspx for a bit of background information.

In VS2010/FxCop 10.0, there's a new /assemblyCompareMode command line switch for fxcopcmd.exe that allows you to specify the comparison mode without mucking about with the .config file. You can specify this in you VS project by using the CodeAnalysisAdditionalOptions MSBuild property.

In addition to peter_raven solution you can specify option to make Code Analysis work with TFS build. Add this in build options, process tab, advanced category in "MSBuild Arguments":

/p:CodeAnalysisAdditionalOptions=/assemblyCompareMode:StrongNameIgnoringVersion

Use this if you need to turn off Code Analysis.

In Visual Studio 2012,

  1. Right click on your project and select "Properties" from the popup menu.
  2. Click on "Code Analysis" tab and uncheck "Enable Code Analysis on Build"

Clean and Build. Code Analysis error should go away.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!