FxCop on build (Visual Studio 2008 Professional)

元气小坏坏 提交于 2019-12-01 10:39:44

Try putting this right before </Project> in your csproj/vbproj file:

<PropertyGroup>
    <PostBuildEvent>"%25ProgramFiles%25\Microsoft FxCop 1.36\FxCopCmd.exe" /file:"$(TargetPath)" /console /searchgac</PostBuildEvent>
</PropertyGroup>

For executing Fxcop after build, use the Fxcop task of MSBuildCommunityTasks in AfterBuild target:

<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>

<Target Name="AfterBuild">

  <FxCop TargetAssemblies="@(OutputAssemblies)"
         RuleLibraries="@(FxCopRuleAssemblies)" 
         DependencyDirectories="$(MSBuildCommunityTasksPath)"
         FailOnError="False"
         ApplyOutXsl="True"
         OutputXslFileName="C:\Program Files\Microsoft FxCop 1.32\Xml\FxCopReport.xsl"
         DirectOutputToConsole="true"/>

</Target>

The output will be shown in the console.

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