Thursday, June 11, 2009

StyleCop and FxCop integration in VS 2008 Express

Recently I took interest in improving the quality of the applications I write by forcing them to be checked by StyleCop and FxCop during the build.

StyleCop was really easy to implement - just one line, well documented, nothing one would struggle with:

1. Install StyleCop using MSI installer
2. Add the following line to your project right after the line that imports C# tasks (by default it's nearly at the end of the project file!):

<Import Project="$(ProgramFiles)\MSBuild\Microsoft\StyleCop\v4.3\Microsoft.StyleCop.targets" />

FxCop on the other hand wasn't so easy to find out but it was just as easy to manage:

1. Install FxCop using MSI installer
2. Add the following task to <AfterBuild> target:

<Exec Command='"$(ProgramFiles)\Microsoft FxCop 1.36\FxCopCmd.exe" /file:"$(TargetPath)" /console'/>

That's it. Alternatively you could just add a post-build event using project options editor. This event would then look like that:

"%ProgramFiles%\Microsoft FxCop 1.36\FxCopCmd.exe" /file:"$(TargetPath)" /console

Pretty easy, ain't it?

Here you have a ready-to-check example of the above.


Thursday, June 4, 2009

Mercurial - using "hg serve" to push changes

I've just discovered Mercurial. It's amazing!!! It's a distributed version control system, similar in its flows to git and others from the bunch so if you're already familiar with the concept you'll have no issues working with it.

One thing however is really amazing: it contains a built-in web user interface! Just while being inside the repository type "hg serve" and browse to http://localhost:8000. And there's more to it. "hg serve" can serve as a real server!

There's one thing worth mentioning. If you'd like to use it for hosting a repository there's one thing you have to add to .hgrc (or Mercurial.ini in case you're working in Windows) to make it work:

allow_push = *
push_ssl = false

Otherwise while trying to push the changes you'll get a message saying something SSL and stuff.

And like I said - Mercurial is great - go check it out!