This is a very quick post outlining what you need to do to get NUnit results displayed in your CC.Net results window. There are two steps for this, step one; configure your NAnt build script to call NUnit and step two; get the results merged in CC.Net.
Step 1:
Configure your NAnt build file to reference the NUnit framework and any test files you have in your project.
17 <include name="Test\TestAnnex.cs"/>
18 <include name="Test\TestDAL.cs"/>
19 <include name="Test\TestHelper.cs"/>
20 </sources>
21 <references>
22 <include name="Siberix.PDF.dll" />
23 <include name="Siberix.Utils.dll" />
24 <include name="nunit.framework.dll" />
25 </references>
26 </csc>
27 <copy todir="nant_build">
28 <fileset basedir=".">
29 <include name="*.dll" />
30 </fileset>
31 </copy>
32 <exec program="nunit-console.exe"
33 workingdir="D:\nant_build"
34 commandline="ReportsPdf.dll
/xml:..\test_results\result.xml
/nologo" />
35 </target>
This will dump out the results to an xml file you specify. I have had to re-write the file paths and the commandline element so as to fit on the web page, but you get the idea.
Step 2:
Now configure you ccnet.config file to merge the resultant xml into the cc.net results. This is done within the publishers element.
70 <publishers>
71 <merge>
72 <files>
73 <file>
74 <![CDATA[\test_results\result.xml]]>
75 </file>
76 </files>
77 </merge>
78 <xmllogger />
79 </publishers>
80 </project>
One thing you need to remember is to include the xmllogger element.
Like I said, quick post and not exactly anything new, but you (and I) can use it as an aide-mémoire.
I love that phrase 'in the cloud' and am quite pleased that I have managed to get it into a post. If you are like me and use several different computers to go about your every day life you will know it is a pain making sure your notes and snippets of data are synchronised. Well go take a look at Evernote. It is both a standalone application and web site giving you the freedom to access your notes easily. It has built in functionality for Firefox and Outlook allowing you to either select text from a site and dump it in to a note, or copy the whole web page or e-mail. It is free for basic use, although you can pay for an upgrade in service (the basic package gives you 40meg of space per month cycle). So installing on all your machines will make sure your data is kept up to date and give you easy access.
I apologise if this post sounds like an advert, I am in no way on the payroll of the Evernote company. I have only been using it for about a week and already I have managed to drop all my temp bookmarks in favour of notes that I can now read at my leisure wether connected to the net or not. Go take a look. Just so as not to be biased, there is a similar product called Springnote. I cannot say anything about this app, as I haven't look at it.
A few weeks back I undertook a performance review (no don't worry, its an annual thing). In this review I was asked for my aspirations for the future within the company. My response was to be more agile. My manager initially looked at me as if I meant that I could bend over backwards and touch my nose with my left big toe. As I explained more and more about agile practices (and I am no way an expert, I am still learning about it myself), he became more and more interested, especially as I explained it is a good methodology for environments where there is constant change, which is definitely the organisation I am working in. I gave him a quick run down and demo of the Subversion and CC environment I have set up and explained the ideas behind TDD.
Well It looks as thought it may be going to the next level, I have been asked to give a demonstration to the rest of the IT department showing off the merits of source control and continuous integration (currently I am the only developer practicing this even though I am constantly discussing it with my manager) with the aim of implementing it with the rest of the team. I don't want to enforce agile practices onto my fellow team members, that will have to come from management if they so decide. What I want to show is how it better suits our environment over waterfall methodology as has been practiced here over the past few years, and I plan on doing that in small steps starting with source control and CI. Anyway I don't yet know the date of this demonstration, but when I happens I will report back on the response and any outcome.
A few posts back I listed goals I wished to achieve over the next six months. Currently I am looking in to the Microsoft MVC Framework. I have started by watching Scott Hanselmans' four screen casts over at www.asp.net, these give a pretty good introduction of the framework and what you get out of the box with Visual Studio 2008 with the MVC framework extensions installed. There is also a screen cast from MIX08 here which covers most of the same material, but works as a once over refresher. Jeff Palermo also has a good demonstration on dnrTV. I have found in the past that it is easier to learn about something if you have a set of questions to ask, the natural process of researching the answers leads to a better understanding of the subject matter. So here are a few simple questions I have asked myself.
Some q and a's on MVC
1. Why bother with MVC?
If you are developing large enterprise web applications which rely a lot on view state, do not use MVC. If however you are developing a relatively small web application, perhaps a social network type application, then MVC may be for you. However you can mix and match by implementing MVC within an asp.net web application. Also if you are wanting to develop web applications using a TDD approach, then it may help you as unit testing is fully supported.
2. Does it get rid of the dreadful post-back?
Yes. The ASP.Net MVC framework does not implement post-back, view state or use the web forms event driven lifecycle. This will be a relief to some people, however if you want to store any temporary data between page requests, you need to find another mechanism to do so.
3. What is REST?
REST stands for REpresentational State Transfer and is a mechanism to transfer data via HTTP without utilising any messaging layers such as sessions or cookies. REST applications are generally Client-server, Stateless, Cacheable, and Layered. It can use the HTTP methods of POST, GET, PUT and DELETE to perform the basic CRUD commands for data manipulation. So a URL of /blogs/GET/today can represent a command to retrieve blogs updated today. Microsoft MVC uses a technique called routing which can basically replace the URL above to something more user friendly such as /blogs/show/today.
4. Is it a pattern or a framework?
MVC is a pattern, is well documented and has in fact been around since at least the early 80's. ASP.Net MVC is a framework developed solely for asp.net from Microsoft.
5. Do I still need AJAX, if so how?
ASP.Net MVC works with or without AJAX so implementing AJAX is entirely up to the developer. When the product goes to RTM it will fully support the Microsoft ASP.Net AJAX out of the box, however the developer is free to use any other AJAX framework. Nikhil Kothari has an excellent article where he delves in to MVC Ajax in more detail.
6. Is it just for .net 3.5 or can I use it for 2.0?
The ASP.Net MVC is currently only supported on 3.5. In Visual Studio 2008, selecting a new project in 3.5 gives you the choice to create an ASP.Net MVC project with or without an additional unit test project.
7. Can I run it on IIS6 or is it for IIS7?
You have two options when running it on IIS6, you can either use a wildcard mapping to the asp.net isapi dll or you can map the .mvc extension to it. The former will impact performance of the website, the latter will give less desirable URL including a .mvc extension in the URL. You can employ a rewriter dll such as isapi_rewrite as described here.
Asking myself these simple questions has given me the opportunity to look in to MVC and I have cleared up some of my own perceptions of the whole MVC thing. It has also given me more questions to research such as how to store tempory data without using session or cookies. I hope to expand on these questions in future posts.
My next step is to install the thing and have a good play around with it.
Very basic I know, but it has helped me and it may help someone else.
Here are some links to sites which I have found useful.
Introduction to REST
http://www.viddler.com/Roebot/videos/10/
A Brief Introduction to REST
http://www.infoq.com/articles/rest-introduction
Chapter 4. What is MVC?
http://www.jcorporate.com/expresso/doc/edg/edg_WhatIsMVC.html
Model-View-Controller
http://www.webopedia.com/TERM/M/Model_View_Controller.html
MVC Overview
http://quickstarts.asp.net/3-5-extensions/mvc/MVCOverview.aspx
We have finally finished our migration to SQL 2005 at the weekend. That is 2 migrations to Windows 2003 and 2 migrations to SQL 2005 as well as upgrading our main accounting package. We started on Friday evening, did the main work during Saturday and the testing Sunday, so everyone here is a bit tired now. We have not been able to undertake any development work for the past 2 months because of this upgrade, but now it is over I can get back to what I love; writing code. This lead me to wonder with all the new technology coming out of MS at the moment, what are other peoples stance with older but still useful projects. Do you re-write the old Intranet to encompass Linq etc...
As I have grown as a developer I sometimes look at my old code, shudder and think 'Why did I do it that way, this other way would have been much better.' There is such a difference as to how I code now and how I did just 3 years ago. Do you take the stance of 'If it isn't broke, don't fix it' or do you attempt to get all projects using the same technologies/methodologies, basically singing from the same hymn sheet.
When I started at my current place I wrote a fantastic (well I think) customer facing reporting suite. It runs with hardly any problems, but now I hate the code base so much and would love to re-write it. Should I bother?
It has been a few weeks since my last post, so apologies for that. I have finally passed MS exams 70-292 and 70-296 so I am now an MCSE on Windows Server 2003 at last; hence the disappearing act.
Readers of my previous post and also my old blog will know I have been working with Nant and Subversion over the past few months. Well the time has finally come to marry them together in to a CI system. I have installed and configured CCNet which will monitor SVN and check out files if there has been any changes. The nant build scripts are then automatically called each time to perform a nice clean build. I won't discuss the installation of CCNet as it is pretty straight forward, what I will concentrate on here is the ccnet.config file which is where project configuration is held. Here is a very basic example.
<cruisecontrol>
<project name="testCCNet">
<workingDirectory>C:/Projects/testCCNet/testCCNet/
</workingDirectory>
<triggers>
<intervalTrigger seconds="60" />
</triggers>
<modificationDelaySeconds>10</modificationDelaySeconds>
<sourcecontrol type="svn">
<executable>C:/SVN/bin/svn.exe</executable>
<trunkUrl>svn://192.168.255.116/code/testCCNet/trunk/testCCNet
</trunkUrl>
<autoGetSource>true</autoGetSource>
<workingDirectory>C:/Projects/testCCNet/</workingDirectory>
</sourcecontrol>
<tasks>
<nant>
<executable>C:/Program Files/NAnt/bin/nant.exe</executable>
<nologo>false</nologo>
<baseDirectory>C:/Projects/testCCNet/testCCNet/
</baseDirectory>
<buildFile>nant.build</buildFile>
<buildTimeoutSeconds>600</buildTimeoutSeconds>
</nant>
</tasks>
</project>
</cruisecontrol>
Some things to note:
Notice the forward slash within the directory paths. If you don't know XML then the \ character is illegal within elements, there are three ways around this.
1. Switch it to a forward slash like above
2. Use double back slashes (\\)
3. Enclose the path within <![CDATA[...]]> tags. This tells the XML parser that it is un-parsed character data.
The above script basically checks svn for any updates every 60 seconds. If an update is found then it calls nant using nant.build as the build file. If you don't want to check every 60 seconds and only run a build at 6am then replace the element with this.
<scheduleTrigger time="06:00" buildCondition="ForceBuild" />
You can of course mix and match both intervalTrigger and scheduleTrigger.
If you are building quite a large application, be careful it does not exceed the buildTimeoutSeconds.
The modificationDelaySeconds element specifies how long in seconds since the last check in before attempting to run a build. This is to prevent a build running if a user is part way through committing updates to the source control.
When you install CCNet it creates a desktop shortcut to ccnet.exe. When you have this running, you can keep track of which projects build successfully and which ones don't. If you do not want this running visually or are worried you will not start it up if you reboot the CI machine, then one possibility is to use a utility like System Scheduler from Splinterware. This tool will start up the ccnet.exe application on start up and run it in the background.
Also during install, a virtual directory called ccnet is added to the machines default website (if you have IIS installed). So browsing to http://localhost/ccnet/ViewFarmReport.aspx will give you reports and stats on the status of your various projects.

If you get errors when first loading this page, check what asp.net version the ccnet virtual directory is running under.
I am sure there are a lot of developers out there who already use Continuous Integration (CI). personally I plan on moving over to a CI environment but I want to dip my toes in the water first to see how the various aspects of CI can work for me. Readers of my previous blog will know that I have already set up Subversion. More recently I have started to use NAnt and in this post I will quickly cover how I set it up to be run from VS 2005.
For those of you who don't know what NAnt is, basically it is an automated build tool. It is run from the command line and reads configuration data from a .build file.
Why use NAnt over Visual Studio?
NAnt doesn't need VS to be running to run a build job, so it can be scheduled to run at any time.
It can automatically check out code from your source control.
It can run any unit tests.
If you have any other files which you want copied over to the build directory, you simply specify them.
Firstly you can get NAnt from here.
Once downloaded, extract it to somewhere on you drive.
I use C:\Program Files\NAnt
In Visual Studio go to Tools >> External Tools then click on Add.

You need to specify the buildfile for NAnt. I keep my build configuration for all projects in a file called nant.build in the root of my project. This way going to Tools >> NAnt will build the project I am currently in without having to pass any other parameter. For arguments, use this.
-buildfile:$(ProjectDir)\nant.build
The build file is actually an XML document where you specify tasks for NAnt. Within this XML are <project> and <target> tags where you specify the tasks.
<?xml version="1.0"?>
<project name="myApp" default="build" basedir=".">
<target name="build">
<delete dir="nant_build" />
<mkdir dir="nant_build" />
<mkdir dir="nant_build\Docs" />
<mkdir dir="nant_build\Images" />
Add <sources> and <references> for your project like this.
<csc target="exe" output="nant_build\myApp.exe">
<sources>
<includes name="myClasses.cs"/>
<includes name="stuff.cs"/>
<includes name="Web References\webbyservice\Reference.cs"/>
</sources>
<references>
<includes name="myDLL.dll" />
</references>
</csc>
If there are any files you want to copy over to the build directory use the <copy> tag with the todir attribute like this.
<copy todir="nant_build">
<fileset basedir=".">
<include name="ReadMe.txt" />
</fileset>
</copy>
Now running Tools >> NAnt will compile your app and copy any additional files to a nant_build directory.
There is so much more to NAnt which I haven't even touched on here. As I explore it more I will blog my findings.
p.s. No I don't actually call my files myClasses,cs or stuff.cs, that is just for an example. Although I did know a developer who had methods called DoStuff().
This is something I have come across during our SQL migration which I didn't even think about. You can zip up your bak files and save considerable hard drive space. We have a 14 gig database which happily compresses down to 2 gig. With hard drives coming down in price, you may think why bother. Well in our migration we have two separate domains for testing purposes which have to stay separate at all costs. Compressing our bak files we can burn it to DVD and move it to the test domain regularly for testing our in house applications.
Right I want this compression automated and complete before I come into the office, so I wrote this small utility.
If you find it at all helpful, feel free to use it. It uses the ICSharpCode.SharpZipLib.Zip library which can be downloaded from here.
using System;
using System.Collections;
using System.IO;
using ICSharpCode.SharpZipLib.Zip;
static void Main()
{
ArrayList alFiles = new ArrayList();
DirectoryInfo dir = new DirectoryInfo(".");
foreach (FileInfo f in dir.GetFiles("*.bak"))
{
alFiles.Add(f.Name);
}
for (int i = 0; i < alFiles.Count; i++)
{
ZipNamedFile(alFiles[i].ToString());
}
}
private static void ZipNamedFile(string input)
{
string fileName;
fileName = input.ToLower();
fileName = fileName.Replace(".bak", ".zip");
using (ZipOutputStream s = new ZipOutputStream(File.Create(fileName)))
{
s.SetLevel(5); // 0-9, 9 being the highest compression
byte[] buffer = new byte[4096];
ZipEntry entry = new ZipEntry(Path.GetFileName(input));
entry.DateTime = DateTime.Now;
s.PutNextEntry(entry);
using (FileStream fs = File.OpenRead(input))
{
int sourceBytes;
do
{
sourceBytes = fs.Read(buffer, 0, buffer.Length);
s.Write(buffer, 0, sourceBytes);
}
while (sourceBytes > 0);
}
s.Finish();
s.Close();
}
}
Well everyone is doing it, so I think I will also. I am going to quickly list my goals I wish to reach for the next six months. I think having goals that are achievable is a good thing, when you have reached that goal you can look back and feel good because you have just improved yourself.
JP Boohdoo has a good posting based around how he wrote down the objectives he wanted to achieve and how he managed to stay focused until he became successful in them. This is just techie stuff, there are a few other more personal things I also wish to achieve, but I won't list them here. Ok so this is what I plan to get myself to 2.0
1. Finish my MCSE Upgrade exams - These have been put on the back-burner for too long, I do not want to loose my certification, and it does come in very handy in my day to day job.
2. Get to grips with the latest development methodologies such as Inversion of Control, Design Patterns, Mocking, Unit testing, MVC and MVP, Dependency Injection, and Continuous Integration
Is there a specific order in which I am best to start with. I already practice unit testing, but as I have had no formal training on the subject I am not entirely sure I am getting the best out of it.
I am only investigating these topics to see what I could implement in the real world. I need to think of a good personal project I could create which will give me the freedom to experiment. I will blog about what I learn, but it may come across as too basic for some of you out there, so I appologise for that.
3. Get all my code up to a standard which will pass an FxCop analysis. I am already part way through this, but as I implement changes and refactorings to working code I am implementing better structure and variable naming.
My book list for the coming few months will be:-
Design Patterns: Elements of Reusable Object-Oriented Software
Code Complete: A Practical Handbook of Software Construction
Refactoring to Patterns
Test Driven Development
The Mythical Man Month and Other Essays on Software Engineering
Well that should keep me busy.
I am not listing too much, I think it would be best achieve many small objectives than be completely overwhelmed.
Hello everyone in asp.net weblog land.
Firstly can I say a big thanks to Joe for allowing us mere mortals in to this community.
I am Garry Pilkington and I am an application developer in the UK. I work for a small oil recycling/transport company just outside Liverpool. I have been working with .net since the beta of Visual Studio came out back in 2001 I think. My first .net projects were both web and console applications when I worked in the NHS. After a few years I moved on to Liverpool University where I stayed until 2005. Now I am at my current employer doing a wide range of projects some web based, some windows client apps. I started off like many people going from VB3,VB4 and VB5. For some reason I bypassed VB6 and went straight to VB.Net. The last 3 years though I have been mainly developing using c#.
My previous blog can be found over at http://capgpilk.blogspot.com, but this is where I will be continuing to blog all things .net.
So that is all for now.
More Posts