PartCover.Net and CC.Net Part 2 - Making it pretty.
In my previous post I show how to integrate PartCover reports into CC.Net and promise to look into make the reports look a bit nicer and try to integrate the Coverage metrics into the statistics reports. So I dust off my xslt, pick up two of my favorite books on XML (XML Hacks and XML for the world wide web) open PSPad and started to play around until I got something that I like.
Click here to download the stylesheets.
The summary report
The for the summary I want to show a coverage percentage per each assembly in the project so I based my xsl in the assembly.report.xslt provided with PartCover.
First I changed the table tag and the first row from this:
<table style=”border-collapse: collapse;”>
···<tr style=”font-weight:bold; background:whitesmoke;”>
······<ttd colspan=”2″>Coverage by assembly</td>
···</tr>
To:
<table width=”98%” cellspacing=”0″ cellpadding=”2″ border=”0″ class=”section-table”>
<tr class=”sectionheader”>
···<td colspan=”2″>Coverage by assembly</td>
···</tr>
Integrate PartCover.Net and Cruise Control.Net
A few months ago I mentioned that I was using PartCover.Net to measure test coverage in my projects. I have been really busy but I decided that this week I was going to integrate the reports with CC.Net.
Cruise Control ships with NCover support out of the box but it’s also very easy to integrate other reports as far as they are in xml format and you know (or have) an xml stylesheet to generate html from the report.
Partcover comes with two xslt files one to report results by assembly and a second one to report results by class.
To use this files in CC.Net you need to make a minor change on them or they don’t work.
Let start with the class.report.xslt file.
Open the file using your favorite text editor (PSPad anybody?) and look for this line:
<xsl:for-each select=”/PartCoverReport/type”>
Change it to:
<xsl:for-each select=”//PartCoverReport/type”>
Notice the double back slash, this change is needed because the way of CC.Net works is merging all the reports for all your tool together in a big xml file, so at that moment PartCoverReport is not the root element but a child element of the merged xml file.
Open the Assembly.report.xslt file and add the “extra” back slash in any mention to /PartCoverReport.
Hanselminutes and the passion for software development
Yesterday I listened to show 115 of Scott Hanselman podcast "Hanselminutes", the title was "Finding passion for Software". When I first got the link on my rss reader I wasn’t sure If I even wanted to download it into my mp3 player, I have so much stuff that I listen in a weekly basics that sometimes I skip some episodes of podcast that I don’t find relevant to my interests, but Scott Hanselman is that rare type of communicator that can make interesting very arid topics. Side note: That actually means that there is not such thing as uninteresting "stuff", but is mostly the ability of the person that talks about it who can make it interesting or uninteresting Back to the topic of this post. In this episode Hanselman talks with Carl Franklin about the joys of programming and getting back to basics. The chat moves around what and why development software is (or can be) fun. Both hosts talk about their mentors and the impact they have in their careers and why they love to do what they do. How this have an impact as well on their writing, talking and sharing their knowledge. Carl makes a point about pretentious people that believes that they know it all, or that they know the "only" way to do something. Scott mentions that sometimes you can tell somebody how not to do something, but leave them find a good way to do it, there is a good chance they will come up with a different way to do it and maybe a more elegant solution that anything you may think about. He is talking about using the anti patterns as examples of bad coding. The shows run for a little bit more than the usual 30 minutes and makes for a great listening. Go and check it out.
Javascript, the good parts, the book.
Douglas Crockford is well known from his work on javascript, specially from tools like Jslint and Jsmin. He is working at Yahoo as a JavaScript Architect.He is somehow responsible for the architecture of the YUI library. He is also the creator? of JSON, Javascript Object Notation and one of the best ways to pass data when using AJAX. He gave a talk in 2007 at Yahoo that is available in the Yahoo developer network about The good parts of Javascript. Six or seven months ago I watched the video with my team and everybody love it. We do quiet a lot of Javascript and we are using more and more AJAX to drive and improve the user experience of our sites. We rapidly adapted most of the patterns and recommendations from Crockford in the re write of our extensive JavaScript library.
IIS 7.0 and classic ASP can’t create folder (or upload files).
I was helping a colleague at work to debug an old classic asp script that uploads an image to the server, create some folders if they don’t exist and copy the image on those folders.
He was having a permissions denied error. Of course he added permissions to IIS_IUSR to modify the folder but still the same error. In IIS 5.0 and IIS 6.0 this is the user that you grant permissions to write files to the server.
We search for an answer on google but nothing came up. Actually we found some posts of people that found the same problem, most of them using PHP on IIS 7.0.
Looking at the system users in the machine (Vista Premiun) I saw a user with the name IIS_WPG, that sound like the IIS Worker Process, we give permissions to that user and suddenly the script started to work.
I haven’t tried it with PHP but my guest is that it’s going to work. (I stopped running PHP on IIS long time ago and I stick with Apache even in windows.)
Note on security
If this was a production machine I would probably enable impersonate and create an ad hoc user to upload files and not give access to the IIS_WPG directly.
Nant custom task to delete more than once.
We were having a problem with our build in the CC.Net server.
The problem was that when doing the clean of the build folder sometimes it was failing with the following error. "Can’t delete folder is not empty". The first thing was to check that not other process was accessing the folder. The second step was to make a search on google to figure out if somebody else had the same problem. We only found one case but was too all and they were mentioning to use Nant 0.84 to solve the problem, that is not an option for us since we need support for .Net 3.5.
We have several projects running in the same server with almost identical build scripts, but only three projects have this problem. They have in common that all of them have a large and deep folder structure. Another characteristic of the problem was that the error wasn’t always in the same folder, it seemed totally random.
Forcing the build usually solve the problem, but sometimes we have to force the build more than one time, since it keep failing in different folders.
A build that fails randomly is not a good thing to have in a Continuous integration environment. You want your build to fail for good reasons, like a failing test or a threshold on simian or FxCop, in a few words, you want that when a build fails people pay attention to it. (Actually the ideal situation is that your build never fails because developers are running the build on their machines first, but you may have integration errors).
So after hitting my head into the wall for a few hours I decided to write a custom nant task to solve the problem.
The idea is that we have a task (forceDelete) that take two parameters, a target directory and a number of attempts. Internally the task will try to delete recursivelly the given folder and any folder below it, if there is an error will try again for as many times as indicated in the attempts parameter.
I’m including a zip file with the compile dll and another one with the source code. To being able to compile the source code you will need to add a reference to Nant.Core.dll, located in the bin folder of your Nant location.
To use the task you just need to copy LaTrompa.NantTasks.dll inside the bin folder of your Nant install (or whatever is that Nant.Core.dll is in your machine).
LaTrompa.NantTasks.zip
LaTrompa.NantTasks.source.zip
Notes
This task is super simple and at this moment it’s not raising and error, something that you may want to do to make your script fails if you still can’t delete the given folder after all the attempts.
Nant build scripts template for Visual Studio
I was creating for the 10th time today a nant build file from Visual Studio when I came to the realization that I needed to automate the process a bit more. So I created an item template to include build files. You just need to copy this zip file into the ItemTemplate folder inside your Templates. Usually is My Documents\Visual Studio 2008\Templates\ItemTemplates After that just right click on a project or solution and select Add New Item, at the bottom of the dialog you will see a section called My Templates
Notice the new Nant build file item 
ASP.Net Development server in a custom port
During Scott’s Hanselmann presentation on Dynamic Data at the TVBUG he show a little trick that I didn’t know about and I want to show it here.
It always annoy me that every time you click run ina a web application using VS it runs using the ASP.Net development server and starts in a random port.
So if you want to make sure that the projects starts always at the same port, all you need to do is right click on the solution and select properties
In the property sheet for the solution click on the Web tab:
Change the default Auto-assign Port to Specific port and type a port of your liking.

DevTeach - The best sessions - 1 (MVC submersion)
Jeffrey Palermo gave a great presentation about the ASP.NET MVC framework. If you read my blog you know that MVC is kind of an obsession with me.
The presentation used the codecampserver project that use the last drop of the code for the MVC and the last version of Palermo’s MvcContrib as well.
It was a concise presentation that covered the most important topics (at least from my point of view), it was fast paced and good fun. There was a very nice moment where he shows up how to use a controller to render different views. Sometimes return Json data sometimes return a web page. You can also see something similar at Iridescence.
It was very interesting to see the architecture of codecamp, he uses a Layered onion architecture for the multi tier architecture, very interesting concept. I think that you may have used something like this but I never saw this graphical representation and makes a lot of sense. The most traditional representation doesn’t work as well as this one. At least for this type of applications. I recommend that you download the slides for the presentation and take a look at it.
One of the things I like the most is that he include the Test as a layer of the architecture. This is important because It make the test first class artifacts on the solution and not an after though or something that can be considered as trivial.
I almost forget, Palermo played some very cool music before and after the presentation.
Palermo posted the material for this presentation on his blog.
REST, a video about it, and a book to rule them all.
I seriously believe that REST is a simple and yet powerful architecture that can be used in most scenarios where web services need to be deployed.
This week the good guys at infoq.com have an interview with Pete Lacey a fervent proponent of REST where he explains the reasons behind his passion. He talk about it and about the WS* stack and why he things that is bloated and not very useful.
I tend to agree with him in most of his opinions specially when talking about security and transactions. I do think that HTTPS is good enough (not actually is very good!) and you can on top of that roll your own security. On the issue of transactions I always thought that not just web services but services in general should be transaction agnostic.
What I mean with transaction agnostic? The service may be part of a transaction but should have no knowledge of it. So the service will receive a request with a payload and sometimes, maybe, return a result. So when you delegate work on that service you should account for that maybe, what happens if the service is not available, etc.