I have VS2012 and local tfs2012 server. I need, when I check in code, some activity check code by StyleCop.
I need that not code that doesn't pass the rules in StyleCop doesn't get send to TFS. No check-in on build time.
You can customize your build template to use the StyleCop Activity included in the TFS Community Build Extensions. That's how I do it.
You can integrate StyleCop with MSBuild so it will be run during every build of your project.
Have a look at the documentation on the StyleCop project page