views:

387

answers:

1

OK first some background. I am busy automating our build process. We run a mixture of Vs 2005 and VS 2008 both targeting platform 2.0. We use Nant to do our builds using the MSBUILD task to do the compile and Cruise Control .net to do our CI. Currently we treat all warnings as errors, fail the build if any FxCop rules fail (except a small subset that we disabled), fail the build if Simian detects any code duplication of more than 5 lines across all projects.

I have written NDepend CQL query to enforce a few rules that are hard to implement in FxCop. I want to fail the build if the number of lines in a method/class breach a certain limit. I also want to fail if the cyclomatic complexity of a method is too high.

I can easily run NDepend as part of my build. But I can't get the build to fail if my CQL queries return results > 0

So this is the question:

  1. Has anybody tried something similar?
  2. Is there a Nant task that supports this?
  3. If there is a Nant task that calls NDepend, but doesn't fail the build is the source available so I can add this feature?

Thanks, Stephen

+1  A: 

What we do is actually have a powershell script run right after that parses through the output file, and throws a series of errors with an appropriate message depending on which condition it found. As soon as powershell throws an error the build fails.

Alex
Thanks Alex, how is that working for you? Would you be prepared to share the script? If I make any changes or enhancements I would be happy to feed them back to you.
I have lots of different scripts for lots of different parsings. We do MsTest, CppUnit, FxCop, Code Coverage, Warnings from MSbuild or VisualStudio. We will fail the build on a number of differnt conditions from there. I have never done an Ndepend. I think it should be easy enough to do though.
Alex
If however, you want one of those as an example, just get me your email address and I'll send it to you.
Alex
If you don't want to learn PowerShell, you may also find IronPython a reasonable option.
Josh Kodroff