问题
Is there a way I can suppress .codeanalysislog.xml and .lastcodeanalysisuccceeded from getting dropped in my output directory on build?
回答1:
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>
回答2:
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>
来源:https://stackoverflow.com/questions/24472559/suppress-codeanalysislog-xml-and-lastcodeanalysisuccceeded-files-from-getting