views:

555

answers:

1

I'd like to use MSBUILD to check the validity of both the rendered HTML and CSS of all pages in a site, and break the build on errors.

Can anyone recommend a strategy to validate HTML and CSS in an automated build? Are there any tasks out there to do this now?

+7  A: 

I can't tell you how to do this in MSBuild, but I can tell you how I would approach this task.

  1. Download the W3C CSS Validator
  2. Run it as a step in your CI platform (Hudson or CC.net) against all your .css files
  3. Find a downloadable Markup Validator, (W3 & WDG, thanks David!)
  4. Find a way to host all your dynamic pages (IIS, maybe WebDev.WebServer.exe)
  5. Download the content of all the dynamic pages***
  6. Run it against the Markup Validator as a step in your CI platform.

*Step # 5 will be somewhat tricky because you'll likely have to maintain a list of URL's to test, since you cant just open up the .aspx files, and if you're running MVC, the urls will be almost impossible to automatically generate based on the files themselves due to routing etc.

Seems like someone could easily make a CSS (maybe one for staic html too) validator plugin for Hudson or CC.net quite easily, you could even display the results quite nicely in a trend graph, etc.

I haven't played around with using MSBuild to do this stuff too much because I use Hudson. However, I think you should be able to do all of this quite easily as post build commands since its all just command line stuff.

Allen
Downloadable markup validators: http://validator.w3.org/source/ http://htmlhelp.com/tools/validator/offline/index.html.en
David Dorward
Thanks David, looks good
Allen