Archives / 2006 / November
  • How to Use Msbuild.exe with CruiseControl.NET

    I just updated my primer/tutorial/walkthrough on CruiseControl.NET with some information about how to use msbuild.exe instead of devenv.exe in your minimal configuration. One good reason to go with msbuild is that you don't need to install VS.NET on a dedicated build server, and you can also target unit tests, performance tests, code analysis etc. that you may have added using the Team Edition versions of VS.NET.

    Please check it out and comment on it if you please.

  • System Restore...

    I'm not sure what has happened with the WinXP Automatic Updates lately, but a while ago I noticed (for the first time) I had an option to Shut down and install updates at the same time. I tried it the second time I saw it and naturally it hung my whole system.

    The machine wasn't working properly after that of course, but I managed to get in and install the updates more or less manually.

    Today I got new problems with the updates. It started with a crash in the svchost.exe process and I tried to debug and see what it was. Windows popped up a webpage telling me there was a fix for this specific "Generic Host bla bla bla" problem. I installed it, it told me it won't fully work until I restart my machine. Alright, I kept running for a while, got the svchost.exe crash again and decided to restart.

    After the restart, WinXP wanted to start install some Updates it appearently had in queue! At login? Weird. It didn't ask and I couldn't stop it. Of course the installation failed as it hung my whole box. I let it sit there for a long time before I decided to restart the machine.

    Anyway, what saved me today was to restart the machine, hit F8, select to start with a "configuration that worked" or whatever the menu option says. Now I'm in, I've configured Automatic Updates in a way so that I will decide myself when to download and install. All seems to work WAY better now.

    I wonder how far away SP3 is... I think I'm going for Vista as soon as I get my hands on the RTM version.

    UPDATE: LOL, I was too fast... after this "manual" Windows Update and the recommended reboot, I got a new crash after logging into Windows, now it was the AutoUpdate.exe crashing on my... yeah... LET ME WORK FOR LOVE'S SAKE!

  • [Podcasts] Podcast Aggregator - Doppler

    My buddy Jan-Erik has been listening to podcasts for a while now, and he pointed me to a program called Doppler which seems to be a decent podcast aggregator. I've only just started to use it, but it looks nice and seems to behave well. It got all the bells and whistles we're getting used to nowadays - async downloads, system tray, notifications and so on, and you can turn these features on and off as you please.

    Go check Doppler out at

    Now I need to look for a seamless way to get these things over to my Sony Ericsson mobile without too many clicks.

  • [Podcasts] New Podcast - Without a Name

    Found a newly started podcast, one which haven't got a name yet even. So far called "developer podcast", but they would like to get some ideas for a name. "They" are Derek Hatchard and Mike Mullen and you find links to their own blogs from their podcast site. They have recorded 2 shows so far and the sound quality could be better, but they give some good tips about Vista which are useful and have some links to resources they talked about on their blog.

    You find these guys at

  • FolderShare - The Best Utility of the Year?

    Oh yeah! Thanks to Scott Hanselman for podcasting and blogging about this tool, and thanks Microsoft for making this one a free Windows Live Service. Most of you know that Scott is testing most of the software tools that ever gets created and let me quote some of the things he's saying about FolderShare:

    Sure, there's other applications that have tried to solve problems like this before, but holy crap FolderShare nails it.

    There's so much you can do with it, like automatically mirror pictures, music and so on across your machines with a few clicks. They just have to be connected to the Internet. It's also secure. I now have my IE Favourites synced between my machines, and it was done with like 2-3 clicks.

    Even though it's free now, you got a few limitations to how many folders and files you can share right now. That will probably change in the future. If you look at you see that there is a limit to 10 folders and 10.000 files at the moment, but hey, that will take you far. I've also seen a max filesize of 2GB being mentioned on the FolderShare web site so I'm not sure what's the deal here.

    It's beautiful anyway, go download already!

  • [Podcasts] .NET Podcasts

    I've soon listened to all shows that have been recorded by Scott Hanselman and Carl Franklin on Hanselminutes (, and I've started to dig around for some more podcasts, preferably similar to the Hanselminutes stuff. I've been listening to .NET Rocks ( for some time as well, and I just ran upon the Polymorphic Podcast ( which seems to be just great. Polymorphic is about most things .NET related and it's hosted by Craig Shoemaker.

    Then there's the ASP.NET Podcasts, hosted by Wallace B. (Wally) McClure and Paul Glavich, which I haven't listened to (or looked at for that matter because they also have some viewable material) at or better yet

    If you know of any other similar podcasts, please let me know and I'll add them to this page.

    I need to think of a way to automatically download the files and have them synced with my SonyE ricsson mobile phone... Or get a better "download deal" with my phone company and create a small program that I can run on the mobile phone to download these podcasts directly. It's too expensive for me to download these files over the mobile network as I have to pay for the bytes...

  • How to Hook Up a VS.NET 2005 Solution With CruiseControl.NET in a Few Minutes

    This is a short "primer" on how to get your CruiseControl.NET (CC.NET) Continuous Integration (CI) Server up and running with a very small configuration, and it will only take you about 5 minutes or so. I’m pretty new to CC.NET so I thought I would share some of the stuff I learned about it when setting it up. I've used it before, but that was some time ago and now I’m planning on using it for an upcoming project so I had to brush things off and see what had changed lately.

    I’m listing some NAnt resources as well here, even though I’m not covering NAnt now (but probably will in a future update). If you want to read about NAnt and CC.NET, Joe Field got a great article on it, and I'm sure there are other CC articles out there.


    Nov 25, 2006 - Added information about how to use msbuild.exe and a small sample configuration. 

    Why CruiseControl.NET?

    So why would you like to use something like CruiseControl.NET? Say you have an ASP.NET Web application solution with a few class library projects and some NUnit tests, you keep track of it using VSS and you want to make the move to CI. Say you want it to check out, compile, test and report every time new code is checked in or by schedule every night (this is up to you and dead simple to change). If this is something you’d like to do, keep reading.

    Note that this has nothing to do with the Unit Testing features of (some of the) VS.NET Team System Editions, but CC.NET is so flexible it’s possible to use that feature too, via the <msbuild> <task> for example, but that’s for another time. I've updated this page (at the end) with a sample configuration for compiling using msbuild, but not for running unit tests with it (yet) 

    If you know the basics and just want to get to the configuration file, jump to the section near the end called “CC.NET Configuration” where you got the XML I came up with. Good luck.

    Tools and Products

    I'm using these tools and products:

    - Visual Studio.NET 2005 + Visual Source Safe

    - CruiseControl.NET version 1.1.2527, tool for doing Continuous Integration

    - NUnit version 2.3.6293 for .NET 2.0, tool and framework for unit testing your code

    - NAnt + NAntContrib version 0.85, tool and framework for performing complex build tasks, similar to msbuild.exe. The Contrib

    package contains extra stuff you want to use as a NAnt user (not used in this paper yet, but make sure it’s the same versions if you decide to install them now)


    Some good reasources, where you can download the things I listed above:

    - CruiseControl.NET–

    - NUnit –

    - NAnt – (not used in this paper yet)

    - NAntContrib – (not used in this paper yet)

    - Great (longer) tutorial on CC.NET by Joe Field -

    Ways of Building Your Code

    Just a few words about different ways to build/compile your code. There are various ways to do this of course, but a few typical ones:

    - Let CC.NET build it by using the devenv.exe program (this requires you to install VS.NET on the build server)

    - Let CC.NET hand over the build process to msbuild.exe.

    - Let CC.NET hand over the build process to NAnt, which in itself can use devenv.exe or msbuild.exe to build you code.

    Using devenv.exe is a simple way of doing it, CC.NET got a <task> for it, you just point at your solution file, and I’m sure it will be enough for most people who just wants to get going. But, it won’t give you the precise control you might want to have.

    This paper will cover the first one, using devenv.exe, and the second one using msbuild.exe, but it should be enough to get you started.


    This tutorial assumes that you already have VS.NET 2005 installed. So start off by downloading the other products listed above. There’s no need to install NAnt unless you want to use that as your build tool. The simplest configuration of CC.NET handles the build on its own, without even involving msbuild.exe, but I recommend that you look at, learn and consider using NAnt for more complex/complete build tasks. You find the links in the Resource section.


    Installing these things is pretty straight forward and needs no help. A few words though... Most of these products are actually mimicking the beautiful way most Java tools are installed – unzip into a directory of your choice. But I recommend using the .msi installers, especially that of CC.NET as it installs a Windows Service as well and a few useful shortcuts to the CC.NET configuration file and the documentation.

    The CC.NET .msi installer also creates a website (CC.NET Dashboard) on your IIS if you got that installed. For some reason it doesn’t create any shortcuts to it from the Start menu. I’ll talk about that later.

    Speaking about documentation I have to say that the docs are great in most places. Thing is that the stuff you need to read are spread out in several places and I couldn’t find any decent CC.NET configuration that suited me. That’s why I’m writing this paper...

    My Test Solution

    So, we need something to test on, so I created this mini web app, which consists of 3 VS.NET projects:

    - A web app (I used the Web Application Project template for this)

    - A class library for a simple Database Access Layer project

    - A class library for a few unit tests (using NUnit)

    Make sure you install these things so that the solution file is sitting in a folder “above” these projects, like this:

    Solution (JohansTestSystem)

              Web Project - Johan.Web

              DAL Project - Johan.DAL

              Test Project - Johan.Test

    This will make everything sort of easier for all tools to handle the code and the projects. Start by creating an empty Solution and add new Projects to it as you go. VS.NET will make sure everything gets created where it should. It doesn’t matter where on your disk you are creating these projects, because we will check them out to and build them in another directory.

    Finally – add them to Visual Source Safe (or whatever source control system you are using). CC.NET got support for many source control systems.

    CC.NET Configuration

    Now, to the reason why you are reading this – let me show you an example of a pretty slim configuration to start with. You find the configuration file (ccnet.config) in the /server/ directory of where you installed CC.NET, or via the Start menu created by the CC.NET installation. My examples does not involve NAnt at all right now and will let CC.NET handle the build by calling the devenv.exe or msbuild.exe.

    Devenv.exe Configuration Sample 

    To understand why this first configuration file looks it does, I'll give you some info about where I have installed things and such:

    - VSS is installed in C:\Program Files\Microsoft Visual SourceSafe\

    - My VSS database is installed in C:\VSS\

    - I got a user called “Johan” in VSS

    - The solution file is checked into the VSS-project $/JohansTestSystem.root

    - I’m checking out and building the solution in the C:\CI\ directory, which means the solution will be checked out to C:\CI\JohansTestSystem\

    - I want CC.NET to look for newly checked in files every 60 seconds

    - I want CC.NET to use VS.NET devenv.exe to build my solution

    - I got NUnit installed in C:\NUNIT\

    - I want NUnit to test the application after the build

    This is a small, if not the minimum, example of a configuration file for this job:


      <project name="Johans Test System">

        <sourcecontrol type="vss" autoGetSource="true" applyLabel="true">

          <executable>C:\Program Files\Microsoft Visual SourceSafe\ss.exe</executable>










          <intervalTrigger seconds="60" />







            <executable>C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\</executable>



          <nunit path="C:\nunit\bin\nunit-console.exe">








          <xmllogger />





    You may want to consider not labeling the code after a build (applyLabel="false") and use another trigger instead of the <intervalTrigger>.

    Msbuild.exe Sample Configuration

    Now I'll show you how to change the configuration above to use msbuild.exe instead. One good reason do use this configuration is that VS.NET does not have to be installed on the build server. NOTE! If you're using the new Web Application Project template for a website project, you must copy the file Microsoft.WebApplication.targets to C:\Program Files\msbuild\microsoft\visualstudio\v8.0\webapplications\ directory, or the build will fail! The reasons for this is described in several places on the Net.

    The circumstanses described earlier are still valid, except that we're using msbuild.exe instead of devenv.exe. So, change the ccnet.config file to look like this:


      <project name="Johans Test System">

        <sourcecontrol type="vss" autoGetSource="true" applyLabel="true">

          <executable>C:\Program Files\Microsoft Visual SourceSafe\ss.exe</executable>










          <intervalTrigger seconds="60" />








            <buildArgs>/noconsolelogger /p:Configuration=Debug /v:diag</buildArgs>





          <nunit path="C:\nunit\bin\nunit-console.exe">








          <xmllogger />





    The changes are in bold. The <msbuild> task and the values should be pretty straight forward and they are well described in the ccnet documentation for msbuild. Msbuild doesn't come with XML output so a few friendly people made an XML logger for it, which you need to download and put in project working directory (for me it's C:/CI/JohansTestSystem/) and also reference in the <msbuild> task section (as you can see above). Read about msbuild and the logger on this page.

    Finally, you need to do a few touches to the Dashboard configuration, which is the file called dashboard.config in c:/<ccnet>/webdashboard/ directory. First, add the compile-msbuild.xsl to the <xslFileNames> section, so that you get a somewhat nicer looking style to the msbuild output:













    You could remove the other files that you're not using, or just leave them there, it doesn't hurt. Then you would like to add the msbuild output to the dashboard menu. In the same configuration file, add a <xslReportBuildPlugin> section:

    <xslReportBuildPlugin description="MSBuild Output" actionName="MSBuildOutputBuildPlugin" xslFileName="xsl\msbuild.xsl" />


    Now, start CC.NET by clicking on the CruiseControl.NET shortcut on the desktop or find it via the Start menu, or look for ccnet.exe in the /server/ directory where you installed CC.NET.

    Even better might actually to be to open up a command prompt and run it from there, because you may get at few errors or warnings the first time and it’s easer to CTRL-C and look at them from there. Don’t bother starting the CC.NET Windows Service until you got a decent config that works well.

    If all is well, CC.NET should do its job and go back to sleep mode again, waiting for the next time to trigger. You should have gotten loads of output in the console window and something like this in the end:

    [Johans Test System:INFO] Integration complete: Success - 2006-11-11 18:45:23

    If not, go back and look at your config file where some path might be wrong. The errors output from CC.NET isn’t the best...

    The CC.NET Web Dashboard

    If you want to look at the results from the last build, or force a new build, you can use the CC.NET Dashboard. Note that ccnet.exe must be running.

    Open a browser and go to http://<your CI host>/ccnet/ and you should see the dashboard where the right hand side shows the projects described in your configuration file, in this case only one project. Click on your project name and then on the report for the latest build which will show you the files modified since last time (and by whom), and how the test run went.

    On the left hand side you can click on a number of links to get detailed reports if you like. The NUnit Details report is a good one, and as you can see, CC.NET got support for a number of other tools; NAnt, FxCop, NCover and so on.

    That’s it for now. This page will probably get updated with other sample configs where I use NAnt and other configurations with msbuild. As soon as I get a few minutes to write something...

  • Installing .NET 3.0 and Orcas... (or perhaps call it) An Ordinary Saturday in a Programmers' Life

    Note of warning - don't follow the steps I did. Better make sure you install things in the right order. Have a quick look down at the end where I have a "Lessons Learned" :p

    The Logbook

    It's Saturday morning and I'm about to install .NET 3.0 and Orcas and whateverelse I might need to get a proper 3.0 platform up and running on a WinXP VPC. It's 11am and I won't be sitting in front of the box all day to do this because I got loads of other stuff to do. The plan is to uninstall a few old things, then do something else, then download one part, install it and do something else and keep doing this until thing seem ok. Goal is to have a decent WinXP + .NET 3.0 + Orcas install to play around with by the end of the day :)

    11:00am - Need a new VPC machine to install things on, so I start by taking a copy of my (almost) vanilla WinXP SP2 VPC file I always keep handy.

    11:30am - Phew! That took a while to copy... I'm in there now, uninstalling a few old things I no longer need. I noticed I copied the wrong VPC file so I got a few old WinFX things I need to remove.

    11:55am - All done, downloading the SDK setup file... BTW, Nicholas Allen got a page where he lists things you need to install:

    12:10pm After reading up on some things, I started the install of "Microsoft® Windows® Software Development Kit for Windows Vista™ and .NET Framework 3.0 Runtime Components". It complains that I still got a few old things I should remove (FxCop etc.) and retry install. That's a good one Microsoft. Thanks. Uninstalling and retrying... this install is downloading during installation, so it might take a while. I'm off to do something else while that is running... BTW. The full install requires some 2.3 GB of disk space.

    12:18pm BANG! Installation bombed. It crashed during the FxCop installation it seems. I wanted to read about the error, but when the "report to ms" dialog was done, it closed the installation dialogs... I guess I should restart XP and restart the installation again... gah!

    12:25pm It says I must first install the old version... here goes. What old version? Taking a look at the installed programs and uninstalling whatever seems to be related to any SDKs...

    12:40pm Ngggh... still refusing to install. Uninstalling even more and trying again. Lessons learned - start out with a very, very fresh XP + VS.NET 2005 box. Kids, don't try this on your daddy's machine at home. I think I'm off to cut my hair and have something to eat.

    15:30pm Right, I'm back. I've unistalled everything I think is remotely related to the old WinFX stuff, and also let WinXP finish installing a few updates it had on queue... took a while it did. Starting a new install of .NET 3.0 SDK again. Next, next, next, next... BANG! My whole VPC now crashed as the installer was about to start doing its real work. Jeeeez... what is this?

    15:35pm Starting VPC again and we'll see if the install works better this time. Wow... it's actually looking good now.

    16:20pm Still installing...

    16:25pm Done! Now on to the next install, Visual Studio 2005 extensions for .NET Framework 3.0 (WCF & WPF), November 2006 CTP, starting now...

    16:55pm I'm back. Had something to eat. Right, installing the Orcas stuff didn't work, because it needs the .NET 3.0 runtime stuff on the machine... Weird, because one would think it got installed with the SDK... whatever, installing the runtime now. Seems that I didn't read right stuff :D

    17:55pm This is your host this evening, back from driving my daughter to a street dance show she's in. The runtime is installed and I'm back in track again - time to install the WCF/WPF extensions... why does the task "merging of the help collections" give me the chills? Because "merging of the help collections might take some time"...

    18:15pm Everything looks fine, now installing the Workflow extensions... Why does all these installation look different? Seems like every team at Microsoft is using their own installer and tools for making these packages? One would think that there were some kind of guidelines that they should try and use the same templates. Anyway, as long as it works I'm happy.

    19:15pm Took a break. Workflow Foundation extensions seems to be installed OK, time to fire up VS.NET and see if it works :p

    (a few minutes later) It works!! Yay! I need a drink...

    Lessons learned:

    a) Make sure you got a few hours of spare time...  ;)

    b) Try to have an as clean as possible machine from start - WinXP SP2 and VS.NET 2005, that's all. Use a virtual machine if possible, don't mess up the box you're working on every day.

    c) Remove anything even remotely related to older .NET 3.0 / WinFX installations.

    d) Install things in this order:

       1. Microsoft .NET Framework 3.0 Redistributable Package 
       2. Microsoft® Windows® Software Development Kit for Windows Vista™ and .NET Framework 3.0 Runtime Components
       3. Visual Studio 2005 extensions for .NET Framework 3.0 (WCF & WPF), November 2006 CTP
       4. Visual Studio 2005 extensions for .NET Framework 3.0 (Windows Workflow Foundation)

    e) Voilá, you're (hopefully) done, start making your first WPF app or something already!


  • [.NET 2.0] On Battery or Not

    I'm thinking of writing a small utility to manage which of my apps gets started at startup of Windows, depending on if my laptop is running on batteries or not. Normally, when I boot it up on batteries, I don't want to start things such as my blog reader and a few other things.

    The thing is it's very simple to detect from .NET if you are running on batteries or not. The SystemInformation type gives you all that and more:

    using System;

    using System.Windows.Forms;


    namespace BatteryConsole


        class Program


            static void Main(string[] args)


                PowerStatus ps = SystemInformation.PowerStatus;


                if(ps.PowerLineStatus == PowerLineStatus.Online)

                    Console.Write("Your power cable is connected, and ");


                    Console.Write("You are running on batteries, and ");

                Console.WriteLine("your battery level is on {0}", (ps.BatteryLifePercent * 100) + "%");





    I'll get back if I ever get that small program written.

  • [Podcasts] Hanselminutes is Cool

    I've started to listen to podcasts on my mobile phone while commuting to where I work at the moment, and it's pretty cool. I've listened to quite a few shows by Scott Hanselman and Carl Franklin available at and I am surprised (well not really) by the quality. It's relaxed, sit-back kind of shows and Carl asks very good questions. You also get some very good tips about tools and blogs.

    The shows I've enjoyed most so far I think is the one on Test Driven and the follow up on Mock Objects. The one on Infocards were pretty interesting as well, and... ;)

    Have to hunt for more podcasts... I spend lots of time on trains these days.

  • [.NET 2.0][Unit Testing] Good Tutorial on System.Transactions (and Unit Testing)

    On my random blog reading and Googling around System.Transactions and Unit Testing, I ran into a series of short but great articles by Stuart Celarier which actually covers both topics. Stuart teaches the reader about System.Transaction by using unit tests in a very educational (and entertaining) way. 

    He uses NUnit in his articles, but nothing will stop you from using the test mechanism built into VS.NET if you got that Team Edition version. Just use the [TestMethod] attribute instead of [Test] and all sample code in the articles will compile and test well (eventually :)

    Stuart also make use of anonymous methods for testing events that I recently blogged about.

    System.Transactions is good stuff, I wonder if it could be useful to manage "compensating transactions" when dealing with multiple web service calls within a transaction?

  • [.NET 2.0][Unit Testing] Using Anonymous Methods when Testing Events

    I've not used anonymous methods too much when coding, but I ran upon a (what I think is) great use of it when writing unit tests and specifically when you need to test events. Mark Seemann blogged about it some time ago (and got lots of comments), and I've seen it in other places when surfing around a few blogs. No need for me to list some sample code, just head over to the pleh blog and read.
  • [Team System] Getting Rid of Default Document Folders in the Quick Launch Bar

    I just recently blogged about how to display document folders in the Quick Launch area of the TFS Sharepoint portal. Here's a follow-up to that one on how to remove the default folders which are created when you set up a new Team System project. It's all about modifying the Sharepoint template. You should only try this if you are creating a custom Team System Process Template.

    1) Create a new test-project in Team System, don't bother to add any source control to it.

    2) In Team Explorer, remove the Document folders and files you're not interested in. This will be reflected on the project portal. As is explained in detail at the MSDN site, you must also edit the Process Template XML files to reflect these changes to the template content. While at it, you may also delete any reports you don't want (or add for that matter), but again - modify the template XML files to reflect this. I'm pretty sure it will still work well, but you never know, things will probably be messed up if you don't. If you change the portal content, change the XML files (repeat as a mantra).

    3) On the project portal, go to "Site Settings", "Go to Site Administration" and click "Save site as template". This will create an .stp file on the portal that you can download and put anywhere on your Team Foundation Server for now. Write down the name of the Sharepoint template because you need it in the following steps.

    4) The rest about how to add the template to the server and so on is well described on the TFS site on MSDN. In short - Go to the server, add the template to the TFS by using the stsadm.exe tool and pointing at your .stp file. Then get back you your lovely Process Template files and refer to it (by name) in the <site> section of the WssTasks.xml file.

    5) Now, upload the new Process Template to TFS, create a new project and see if it looks alright.

    As I wrote earlier, to change the overall look and feel of the Sharepoint portal, you still need to use Frontpage, but that is something I will go into later.

  • [Team System] Displaying Document Folders in the Quick Launch Bar

    Some people who are editing their Team System process templates and are new to Sharepoint wonder how to publish their own document folders in the menu of the portal home page. There are at least 2 ways - either use Frontpage (which I haven't tested yet), or in Sharepoint go to "Documents and Lists", click the folder in question, click "Modify settings and columns" in the left hand menu and then "Change general settings" and tell it to "Display this document library on the Quick Launch bar".

    To modify the Quick Launch bar when it comes to reports and such, I think Frontpage is the tool. I'll try that as soon as I get Frontpage installed... not even sure which version of Frontpage to use actually.

    Last thing to do is to modify the Sharepoint portal template in a way that suits the new process template, then create a new template out of it, make sure it's installed on the Team System server and then point at it from the WssTasks.xml file:

    <site template="Your_Sharepoint_template" language="1033" />

    Who said creating your own process template for TFS was easy? :) I'll get back to this process in a later post.

  • [Team System] Great Tool for Modifying Process Template

    I found a great tool for those of you who wants to modify the process template - Process Template Editor from imagiNET, and it's free. It won't see to all your needs, but it's a great help and the best tool I've seen so far to get you started. You still need to do some manual XML editing if your goal is to create a completely new template, and I still need to find a good way to modify the document folders and the content within there. So far I've been editing the WssTasks.xml file by hand, and it *beeps*... :)