4

Is there a way I can suppress .codeanalysislog.xml and .lastcodeanalysisuccceeded from getting dropped in my output directory on build?

abatishchev
  • 98,240
  • 88
  • 296
  • 433
Yam
  • 293
  • 3
  • 12

2 Answers2

5

I agree, the bin folder is bad place for these FxCop files. However suppressing these files from getting generated, or deleting them unconditionally after the build is not the best decision. First, removing .lastcodeanalysissucceededd will cause code analysis re-run even when nothing has changed. Second, removing .CodeAnalysisLog.xml will make it almost impossible to investigate details of analysis errors and warnings. So you might as well just turn off the code analysis for the project.

Instead, let me suggest another solution. It solves the problem with those pesky files in your bin folder, while preserving all functionality of FxCop. The solution is simply put those files somewhere else. The best place is obj folder, i.e. $(IntermediateOutputPath).

Paste this section in your project file after all <import>'s, at the end of the file:

  <PropertyGroup>
    <CodeAnalysisLogFile>$(IntermediateOutputPath)$(TargetFileName).CodeAnalysisLog.xml</CodeAnalysisLogFile>
    <CodeAnalysisSucceededFile>$(IntermediateOutputPath)$(TargetFileName).lastcodeanalysissucceeded</CodeAnalysisSucceededFile>
  </PropertyGroup>
Ignacio Soler Garcia
  • 21,122
  • 31
  • 128
  • 207
seva titov
  • 11,720
  • 2
  • 35
  • 54
0

Never mind, I put in a post-build target to delete these files

<Target Name="AfterBuild" AfterTargets="Build">    
<ItemGroup>
    <FilesToDelete Include="\**\*.CodeAnalysisLog.xml" />
    <FilesToDelete Include="\**\*.lastcodeanalysissucceeded" />
</ItemGroup>

Yam
  • 293
  • 3
  • 12