views:

208

answers:

2

I am interested in setting up FxCop to run on each of our VS .csproj files in our developing environment by calling it as a target in the .csproj file itself without creating a separate MSBuild file for the project. Is this

<Target Name="AfterBuild">
   <Exec Command="&quot;C:\Program Files\Microsoft FxCop\FxCopCmd.exe&quot; /searchgac /p:FxCopProject.fxcop /out:FxCopOutput.xml" ContinueOnError="true">
   </Exec>
</Target>

possible to get working in one way or another being included at the tail end of my .csproj file?

+2  A: 

I think you're looking for the post-build event.

  1. Right Click the Project
  2. Click Properties
  3. Go to the "Build Events" Tab
  4. Add the command line to the "Post-build event command line" box.
Jason Punyon
+1  A: 

The following should work - paste it anywhere at just under the node level:

  <PropertyGroup>
    <PostBuildEvent>"%25ProgramFiles%25\Microsoft FxCop 1.36\FxCopCmd.exe" /p:$(SolutionDir)Bank.FxCop /o:$(TargetDir)FxCopResults.xml /d:"%25ProgramFiles%25\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies"
  </PropertyGroup>

Note the /d parameter I'm using to point to where my project is using additional assemblies (in this case, the MSTest unit testing stuff).

Jesse C. Slicer