Search code examples
visual-studio-2010build-automationstylecop

How to add stylecop check as a pre-build action to VS2010?


In our project we have added StyleCop task to be executed after each commit by continuous integration server. The problem is that build often breaks because someone forgets to run Stylecop before commiting code to repository.

The solution will be to execute StyleCop before each VS2010 build. How can I do it? Maybe it is possible to execute pre-build action per whole solution?


Solution

  • It seems you could use MSBuild integration (look here or here), which will make StyleCop checking a part of a build process.

    Or you could use some sort of "commit policies" which run StyleCop during the commit and reject the commit if StyleCop checking is not passed. For example, here is one for TFS.