Archives

Archives / 2006 / December
  • Rethinking your business validation rules

    Last night Tom Hollander and co. announced the release of the December CTP of Enterprise Libraries 3.0 (on CodePlex no less!). I've been watching and waiting for this (even bugging Tom to get a "sneak peek") but it's reality now and something you can play with. After all, opening Christmas presents isn't the only thing geeks do over the holidays. Don't use this for production apps, but if you've got something going into production in the next 6 months, its something to consider.

    One of the main features they wanted to deliver (based on user feedback) was a validation engine. Something that would allow you to validate business entities with little effort. Last night I gave the validators a whirl to see how they worked. It's pretty slick and ends up being a nice cleanup of your domain from clutter (which is always a good thing).

    Let's say I have an Account class and the name of the account has some rules around it. Names are required and can only be between 5 and 8 characters. This is a simple example, but one you should get the idea from.

    First I'll write a set of quick tests for my Account class. Four tests, one creates a valid Account, two test the length bounds, and one creates an Account with a null name.

        6 [TestClass]

        7 public class AccountTests

        8 {

        9     private Account _account;

       10 

       11     [TestInitialize]

       12     public void SetUp()

       13     {

       14         _account = new Account();   

       15     }

       16 

       17     [TestMethod]

       18     public void CanCreateValidAccountWithName()

       19     {

       20         _account.AccountName = "C123456";

       21         Assert.AreEqual(true, _account.IsValid);

       22     }

       23 

       24     [TestMethod]

       25     public void AccountNameMustCannotBeLessThanFiveCharacters()

       26     {

       27         _account.AccountName = "A";

       28         Assert.AreEqual(false, _account.IsValid);

       29     }

       30 

       31     [TestMethod]

       32     public void AccountNameCannotExceedEightCharacters()

       33     {

       34         _account.AccountName = "123456789";

       35         Assert.AreEqual(false, _account.IsValid);

       36     }

       37 

       38     [TestMethod]

       39     public void AccountNameIsRequired()

       40     {

       41         Account account = new Account();

       42         account.AccountName = null;

       43         Assert.AreEqual(false, account.IsValid);

       44     }

       45 }

    Now we'll create the Account class in a more "traditional" sense, checking for business rules validation during the setter and setting a flag called IsValid along the way.

        3 public class Account

        4 {

        5     private string _accountName;

        6     private bool _isValid;

        7 

        8     public string AccountName

        9     {

       10         set

       11         {

       12             if(string.IsNullOrEmpty(value))

       13                 _isValid = false;

       14             else if(value.Length < 5)

       15                 _isValid = false;

       16             else if(value.Length > 8)

       17                 _isValid = false;

       18             else

       19             {

       20                 _accountName = value;

       21                 _isValid = true;

       22             }

       23         }

       24         get { return _accountName; }

       25     }

       26 

       27     public bool IsValid

       28     {

       29         get

       30         {

       31             return _isValid;

       32         }

       33     }

       34 }

    Great, our tests pass and all is good in the world. However our setter looks kind of ugly and could be improved. Maybe we could create some private methods called from our setter, or you could throw a BusinessRulesException but it's still ugly no matter how you refactor this.

    Enter the new hotness of the Validation Application Block of Enterprise Library 3.0. Rather than writing all those "if" statements and conditional checking, we can specify our validation through attributes decorated on the property. And our IsValid property can be changed to use the new ValidationFactory classes:

        6 public class Account

        7 {

        8     private string _accountName;

        9 

       10     [NullValidator]

       11     [StringLengthValidator(5, 8)]

       12     public string AccountName

       13     {

       14         set { _accountName = value; }

       15         get { return _accountName; }

       16     }

       17 

       18     public bool IsValid

       19     {

       20         get

       21         {

       22             IValidator<Account> validator = ValidationFactory.CreateValidator<Account>();

       23             ValidationResults results = validator.Validate(this);

       24             return results.IsValid;

       25         }

       26     }

       27 }

    Makes for reading your domain code much easier and it's a breeze to write. Also (at least IMHO) it makes for reading the intent of the business rules much easier. You can also create your own validators and there are a set of built-in ones in the December CTP drop (String Length, String Range, Date Range, Valid Number, etc. more coming later) so there's much more to it than this simple example but I find it all very slick and easy to use.

  • Ribbon UI Control Roundup for Developers

    After yesterdays post about my babbling about the Ribbon UI and Office 2007, I decided to go out and hunt down all the libraries and controls I could find that provide that UI experience for you, the developer. I've taken out a few hours, downloaded all the samples and demos I could and gave everything a test drive. For the demos and criteria (I'm very picky about having to do silly things like RTFM) I looked at how easy it was to add the control and apply the look and feel of Office 2007 to a simple Windows Form. Was there a designer? Documentation? Demos? How much code did I have to write? Any extra stuff that came easy or for free (like built-in icons, reading in menu structure from XML, etc.) added some brownie points, but not much as the focus was just getting an Office 2007 look and feel.

    For my trial samplings, I went completely commando and took a solution, added a WinForm project for each control, and went to town. If there wasn't anything obvious about how to add controls or get the Ribbon going, I would crack open the demo and, barring that, resort to actually reading something. I also had Word up and running and built a small sample with each library to mimic the Word UI by creating a tab for each section (Home, Insert, Page Layout, References, Mailings, Review, and View), groups for the first tab (Clipboard, Font, Paragraph, Styles, Editing) and button/menus for the first group (Paste, Cut, Copy, Format Painter). Building each demo should only take 10 minutes (no graphics, just setting properties and adding controls).

    Here's a rundown of the toolkits available out there.

    Elegant Ribbon

    A good looking control, implements all the requirements for the Ribbon and is 100% managed C# code. Install was simple and it came with a toolbox entry with some controls you can drop onto your forms. Very simple and intuitive. You could probably get up to speed on this very easily and it appears to implement all the features the real Ribbon does. Demo was quick to build and I didn't have to refer to the help or samples. You can add tabs and groups from the built-in context menu so it's pretty intuitive. Adding the Ribbon to the form also added their own FormFrameSkinner so the entire form took shape with the Office 2007 UI look and feel automatically. Very nice. Beta version only right now.

    SandRibbon

    A nice control and one of the more lightweight but compatible and powerful ones out there. Install couldn't add controls to Visual Studio (but Elegant Ribbon could?) so you have to add them manually. Once you do this you can add a Ribbon to the form. This was fine and I could right-click on a group (they call it a "Chunk") and add controls or new chunks. Overall not bad, but it didn't create the Jewel which Elegant did. If I did some more digging I could probably find out how to do this but it didn't look obvious to the controls that I could add or properties I could set. The only problem I saw was when I reloaded my sample, it couldn't figure out how to build the designer and crashed not understanding a variable called "ChunkStrip". Creating a new form and adding the Ribbon didn't have any problems. Commercial and available for purchase. Eval version is available.

    TAdvToolBar

    Nice implementation. Only for Delphi and C++ Builder. Since I don't have either installed, I couldn't try it out the library but the demo looked like it could do the job and I gave a quick once-over on the SDK documentation and it looks pretty simple.

    XtraBars Suite

    Part of the big gigantic entity known as DevExpress. I do have XtraBars (or DevExpress or something) laying around here but I haven't installed it. If it's anything like the XtraGrid then this is probably the cadillac of Ribbon controls but it comes at a price. I've been working with the XtraGrid for months and I still don't know how to do much with it other than replace a DataGrid. There are just a billion options, designers, editors, skins, themes, and all that so I'm sure that's been packaged into the XtraBars as well. I did run the demo and it looks good so if you're serious about building apps using the Office UI and have lots of time to kill learning something, this would be your best bet.

    BCG Control Bar Pro

    I've used BCG before and their suite is nice. It's all written in C++ but I'm not sure if they've moved over to the managed world yet for this control. They have a (ugh) MFC demo version that looked and behaved well exceptionally well. The thing I've always found about BCG is that their demos are not only the look and feel of the app, but some functionality. For example their Ribbon demo is Word and comes with all the icons, buttons, and graphics as the real deal but also when you click on things like the File Open button or Save toolbar, it brings up a dialog. It's a nice touch that they take more time than just building a Hello World sample but an actual demo (even if it is a shell). As for the library itself, after installing this library there were no Ribbon controls avaialble so I'm assuming they haven't released that part yet but only the demo.

    Janus UI Controls

    These guys claim to have a Ribbon component, but unless I'm missing something obvious, I can't find it on the site.

    DevComponents Ribbon Control

    Simple install and worked first time. Added it's own toolbox with a variety of controls (including a bunch that were not Ribbon related but things like Visual Studio 2005 style tabs, nice). Dropped a Ribbon control on a new form and then added some additional controls. Not completely intuitive about adding groups. The other controls like Elegant and SandRibbon would add tab groups, here you drag the group onto the tab which means you have to dock it and do some alignment (or maybe there's some container control you have to add first). No Jewel added automatically and I didn't see a control for it, so not sure if that's supported. Lots of really annoying nag screens everytime you add a control to your form so negative points for that.

    Toolkit Pro 2006

    This is from the CodeJock guys and they usually produce good stuff. The library is listed as C++/MFC (like BCG Control Bar) so it's MFC only and not a WYSIWYG type environment. Like BCG, you have to build a MFC app (using the template they provide or modifying your own MFC app) and hook in the Ribbon through resource files and source code. Sorry but I stopped doing that development years ago when C# let me focus on my domain rather than writing code to wire up UI events (and MFC is bloatware to begin with). Anyways, again the demos look good but if you're not familiar with MFC or C++, be afraid, be very afraid. If you do like to hurt yourself, this toolkit or the BCG one (if I could find the Ribbon functionality) are fine.

    Bottom line

    If you're serious about the Office UI and want power (as in BullDog hover-board power) then check out DevExpress. I don't think you'll be disappointed. If you're building a small app or something freeware, give Elegant UI a whirl. Even as a beta, it's quite good, easy to use, and looks just as powerful as most of the other offerings. Best of all, it's the quickest to get up and running with a Ribbon from the libraries I tried out. Most of the other ones, if you gave it an hour with any one of them, you would probably "discover" all the ways to manipulate the Ribbon (except DevExpress which would probably require a week). I'm impatient so only gave it the 10-minute litmus test but if I had to make a corporate decision rather than personal one, I would probably spend a day with a few of my favorites.

    Please feel free to add any I've missed.

  • Being a responsible open source developer

    First off, let's start this post by saying I think there are a few key points in computer history where things turned. The introduction of the GUI (even though both Apple and Microsoft just build on what Xerox did); the Internet; Object Oriented Languages; Microsoft Bob. Well, maybe not the last one but the others are valid and there are lots of others gems out there.

    I've been following the Office 2007 UI for quite some time, ever since I got my hands on early dog food alphas from the Office team. While some might not call it innovation, it just makes sense to me and I think it's a well designed and thought out piece of work. Yes, there are those that are not going to get it and require gobs of training and scream and kick and moan and want their beloved File menu and toolbar back. There is the other group where we embrace it and actually like it. I'll be the first to bitch and complain when I'm building presentations where the freakin' buttons are as I'm still getting used to it, but in the end that's it. I'll get used to it, just give it time. I like the look and think it's a good way to go and frankly, Microsoft made that decision long ago and like or not, we have to adapt and live with it (or not, but that's a different blog post).

    Skip ahead a few hundred blog posts and I came across Jensen Harris' entry about licensing the Office 2007 UI. Yes, a 120+ document about how to build the UI is a bit much and frankly I want to see component developers build controls that help me adhere to that standard. As an application developer, I really don't want to build an Office 2007 UI any more than I want to build my own implementation of the Windows Menu System or Toolbar. After all, that's what component developers do and that's why we buy their stuff. So awesome move on Microsoft's part to publish this, make it royalty free for those that want to build stuff. There is a lot of controversy over Jensen's blog post though, as people are questioning what exactly Microsoft is licensing (a concept? that didn't work for the recycle bin did it now) with some people calling Microsoft arrogant and others say they're brilliant. It'll be interesting how that conversation shapes out (and the comments on the post are quite in-depth, I expect this to hit Slashdot any minute now if it hasn't already).

    The licensing does bring up a bit of a pickle. The royalty-free license is restricted to products that directly compete with Word, Excel, Powerpoint, etc. So what does a product like Open Office, that cannot obtain the royalty-free license? And more importantly what if they purchase a copy of an Office 2007 UI component, say from Infragistics, and use it in the product? Is that a violation of the license or not. Licensing is always messy so I'll leave that to those guys to figure out.

    Anyways, back to some of the converging elements of what brings me to write this post.

    A long time ago on a computer far, far, away I gave RSS Bandit a try for reading my RSS feeds. It was a nice product and worked well but after some time, I abandoned RSS Bandit. It was a huge memory hog (which may be fixed these days) but more importantly, the developer kept revamping the UI by using free copies of commercial UI libraries. Three times he flipped out the UI and I thought (as did others) that getting burnt 3 times would be enough and you would stick to something free, open source, or native. Sorry, but if you're providing a free, open source tool, you can't force your users to be bound to a commercial library.

    As I understand it (and this view may be flawed) Dare Obasanjo, the author of RSS Bandit, received a free copy of the UI component for use in the project. Not unheard of on an open source project. Vendors see it as free advertising and it is. However doing this is tying the open source communities hands. We don't have a free copy of the software like Dare does and even if we did (if the UI component was say licensed for RSS Bandit) having the title heavily dependent on a tool that may or may not be there in the future isn't the open source thinking mentality. Imagine if DasBlog built it's foundation on some proprietary messaging system or database you had to buy in order to make modifications for? Where would it be today? Anyways, Dare and his recent post about what he was proposing for the next RSS UI is something that caught the attention of Mike Dimmick. His comment was what Mike called a misuse of the Ribbon concept, and I agree. I looked at the screenshots Dare posted and while they are prototype, they're far from what I think the Office UI is but rather a rather poor emulation of them. In addition, as some of the comments on Dares blog show, RSS Bandit might not be an appropriate application for the Ribbon concept.

    It is confusing as Dare posts later that Microsoft is releasing several new applications this year, all with varying user interface concepts. IE7, Office 2007, Windows Media Player 11. All from Microsoft, all with different interfaces. Even in the Office space, Word; Excel; and Powerpoint; share the Ribbon but other tools like Publisher, InfoPath, or SharePoint Designer do not. What gives? I think Jensen answered this as those products were not the "core" Office products so would not use the concept of the Ribbon. In any case, how do you go from one interface (File Menu, toolbars) to something like the choices we have now? Not an easy switch. If we as developers think the users are going to push back on Office 2007, then we'll be staying far away from that UI as much as we can if we want to keep our users happy. I don't believe in the concept that just because there's new hotness out there, that we should all flock to it, no matter how cool it may be.

    As application developers, we make choices. Sometimes bright, sometimes not so bright. However if we consider ourselves professional, we have a commitment to that professionalism and that's one of providing our customers (yes, even free open source weekend projects have customers) a product worth of its download. If we're dependent on a library or another tool, make sure that you have some plan to abstract yourself away from change. Sure, maybe the cool 2007 UI is the new hotness today but we as developers can, with a bit of forethought, build systems where the UI is swappable or at least "easier" to replace (I've done it many times). Patterns like Model-View-Presenter help with this and think about you can shift gears should you need or want to. What's cool today is cold tomorrow and painting yourself in a corner isn't going to win you any prizes.

    I for one welcome our Microsoft UI overlords and will be looking to incorporate the Ribbon concept in WinForm apps I build where appropriate, hopefully with the help of some free libraries out there but if not, and where I can, I'll use what commercial tools there are to present what I think will be a better user experience for you. I hope other open source and free tool developers out there follow suit.

  • It's not me, its you

    Yes, you as in you and not me. It's you, kind and gentle reader, that's been named Times person of the year. Every year around this time, Time magazine picks out some influential person or persons to be the "Person of the Year". Someone (or something) that has made a difference.

    This year brings about the community thinking so Time copped out and picked "You" as the person of the year. "You" being a collective term that refers to basically anyone with a computer and an Internet connection. Someone who visits sites, reads blogs, uploads videos to YouTube, crushes Elves by bashing their skulls in an online game, and generally carries on like we all do in our online world of knowledge, sharing, and camaraderie.

    Congrats to everyone reading this blog because you're You (according to Time magazine). You are now in the hallowed halls of such dignitaries as Adolf Hitler and the Ayatollah Khomeini. Amazing what happens to you on a Sunday afternoon reading some geeks blog huh?

  • The install that lasted a lifetime

    I don't know what the softies are smoking these days, but the guys (or gals) that put together the service packs need some serious optimization lessons. I downloaded Visual Studio Service Pack 1 yesterday, all 400+ megabytes of it. Sure, it says it fixes over 2200 problems so it has to be big right? Then came the install which involved the proverbial double-clicking on the file and the subsequent waiting. And waiting. And waiting. And waiting.

    Okay, I'm not running the WOPR here but it's a fairly good system. 2Ghz Core 2 Duo processor, 2GB RAM, etc. so I expect at least a little skip to my step. No so when running this crazy installer. First it had to "optimize" and "configure" my install experience, which took about 15 minutes. Then it had to install the actual update. All the time there was little disk activity, the biggest bottleneck on any system, so it's anyones guess what the system is doing.

    Finally after it ran through multiple "configurations" and updated my install of Team Suite, it was done. 1 1/2 hours later. That's just plain insane for a service pack. Even SP2 for Windows XP installed quicker than that. The Visual Studio guys (and Microsoft in general) need to take some lessons from iterative development and release little patches along the way. This big bang approach really sucks as I dread the day I have repave my machine and install VS2005 again.

    A couple of tips to try to keep the time down (as I've heard some people taking upwards of 3 hours for the process). Turn off everything, and I do mean "everything". If you're running a local SQL server shut down those services. Turn off any utilities that's frivolous like FolderShare and whatnot as you won't need them during the update. Shutdown messenger and kill off any extras you have running in your system tray. Also I recommend just running the service pack and nothing else. Don't try to read email or blogs during the update and maybe it'll go a little quicker for you.

  • SharePoint Security Webcast followup

    Thanks to everyone who turned out for the security webcast today on SharePoint. We had about 60-70 people on the webcast and I had a fun time giving it. A large part of the webcast was around the plugin authentication framework and leveraging the ASP.NET membership providers for using forms based authentication with SharePoint 2007. Unfortunately I didn't get to all the slides (40+ slides in 60 minutes) so if there's anything you're looking for more clarification or depth on, just yell.

    As a followup, here's the additional resource links I mentioned during the webcast or will be useful for you with regards to security and SharePoint:

    The webcast recording should be online in 24-48 hours so I'll post the link once it's available.

    And as I mentioned feel fee to bug me via email if you have any specific questions or scenarios you're trying to figure out. I have a few emails already from the webcast today that I'm following up on so watch for some replies to those and possibly some additional fallout blog postings that I'll share.

    kick it on SharePointKicks.com
  • Compacting Virtual Hard Disks with VPC 2007

    As I'm putting together the final touches on tomorrow's SharePoint security webcast (you should still be able to register, after all I'm not having everyone over to my house... well, not quite), I noticed my SharePoint VHD file (the virtual hard disk format used by Virtual PC) has got quite large. This is due to the fact that I uninstalled Beta 2TR and re-installed the RTM bits (along with some other re-installs). Virtual PC doesn't reclaim the space when you delete items in the VM so it never really shrinks. This was a fairly laborious process under 2004 and required a few steps (as outlined here).

    Virtual Disk Wizard

    In 2007 it seems it's become much easier. Shut down the VM, run Virtual Disk Wizard on an existing disk, select Compact and you're done. Reclaimed all my space instantly with it (but took about 20 minutes on a 2Ghz Core 2 Duo). No mess, no fuss.

  • Got Security?

    As part of the Security on the Brain series of webcasts, I'm presenting an MSDN webcast this Wednesday called "Security - End to End in SharePoint". This is a 1 hour webcast on all aspects of security with SharePoint 2007 covering:

    • How to configure authentication
    • How to manage permissions bottom to top
    • How to securely configure a web farm

    This session describes the end-to-end security architecture in SharePoint, including Windows authentication, pluggable forms and Web SSO authentication, groups using SharePoint, system-wide and fine-grained authorization control, developer control over identity and permissions, administrative security options, and upgrade considerations. This session will also cover integration with Active Directory® Federation Services.

    You can still register for the webcast which starts at 1PM EST here. See you there!

  • MSDN community content - the right way to go, almost

    Quite some time ago I found out MSDN was moving towards a community content driven approach. A wiki style approach to the vast tome of knowledge known to us as the MSDN Library. This was a good move and I wanted to see it blast off as soon as possible. However the implementation has been somewhat lackluster.

    When I found out about MSDNWiki I was excited. The PHP and mySQL community have had a feature with their online documentation where users contribute information about each of the topics. Items like bugs, workarounds, examples, and further explanation of the topic are scattered throughout the original documentation. It's an absolutely wonderful environment because not only do you get the syntactical expressions of how to call say ctype_alnum in PHP, but you also get a tip that it could behave strangely depending on the type you pass it. Brilliant.

    Here's an example of the user defined types in mySQL from the community:

    User Comments

    Posted by Joey Bartlett on April 14 2006 7:54am
    These are very useful. You can use them for ranks.
    Example:
    SET @pos=0;
    SELECT @pos:=@pos+1,name FROM players ORDER BY score DESC;

    This is the way community content should be. Only last week I was reading someone's blog that they went to the SharePoint SDK online only to find 3 or 4 properties with the bare bones, auto-generated documentation that provided nothing for them (or others).

    However the implementation of MSDN community content falls a little short. Sure, users can go online and add content to some areas in the documentation. Some. Community content in MSDN documentation isn't about items that have content, it's about the content itself. Don't give me a mechanism to find entries that have content added to them because that's not how we use documentation. We use it by going to the class that we need help on. If there's content for that particular topic, great. So my suggestion is just open up all topics to community content. I've read through various junctions that "many other developer sets will add this feature over the next few weeks and months". What are we waiting for? If Microsoft is serious about engaging the community and have us supplement their documentation with real-world experience, tips and tricks, and information that's better than a skim of the XML comments in their source code, then we need to be engaged; fully, madly, deeply.

    In addition, I personally prefer to use my local help as the primary source but in this day and age surely Microsoft can figure a way so that when I use my local help it can, in addition, supplement each help topic with comments from the online community? Am I asking for too much here? I don't think so. Each help topic, local or otherwise, needs to have a section at the bottom of it where anyone (maybe via your Windows Live login) can author content. A simple snippet of code, a simple tip or advice on the method or property in question. If I'm disconnected then just display the help content for me sans community content. This is neither rocket nor science. 

    Why can't my world be like this someday:

    MsdnWikiWithUserComments

    We could get this today without Microsoft's help although I'm not sure I want to go down that path (or if I legally could do it). Someone could setup a web site with a simple app where you create an account (for identification purposes, basic stuff like email and name) and use that account to author content. Someone else could decompile the CHM files into their separate bits and writing a small utility, inject a link to the online site in order to pull down user contributed content and insert it into a new CHM. Additionaly, using IFrames, the online site could combine the MSDN and contributed content to form an experience like what the mySQL and PHP documentation sites do now. Like I said, this is just off the top of my head and not a solution by any means and there may be issues with republishing Microsoft content; not all documentation is in CHM format; blah; blah; blah; blah.

    Wouldn't it be a wonderful world if we looked up the documentation for Microsoft.SharePoint.Help.HCLockAction and actually found contributed content from users who have done something with this enumeration? Or an example of what you would use it for? Or something other than the auto-generated docs spit out from code comments that tells us nothing because the product team was focused on delivering the product (which is what they should be doing).

    Now that is real community content. I can only wish we move towards that model someday. Nudge, nudge, wink, wink, say no more, say no more.

  • Nothing but SharePoint MVPness

    If you're looking for the best SharePoint info then look no further. The Newsgator folks have put together an OPML with all of us SharePoint MVPs in it. Very nice to simply subscribe to this and you'll get the entire gang in one feed. Check it out here.

  • Visual Studio for Database Professionals on MSDN

    Just saw that the Visual Studio for Database Professionals is on MSDN now. It RTMed earlier this week but you can download the DVD image now. Also there is the MSDN Library to accompany it and for those without a Team Suite license, a trial version is available. I'll be doing some more posts on this later as I'm doing a demo next week of it and it's cool capabilities for the DataGuy (or DataGirl) in you.

    Also I found a little tip that might help you in avoiding to download the 3.2GB version. If you have a copy of Team Suite installed (not a specific flavour like Developer, Test, etc.) then you can download the file marked "Trial" (the 20MB one). When this version is installed over top of a copy of Team Suite, it becomes a full copy. Why you can do this and avoid the 3.2GB download of a DVD image is beyond me, but then I'm not into the whole marketing thing.

  • MSBuild, NAnt, NUnit, MSTest, and frustration

    Oh bother. Visual Studio 2003 and Cruise Control.NET. Simple and elegant. A basic NAnt script to build the solution and you're good to go. Run NUnit, output goes to a format CC can understand and Bob's yer uncle. Let me quantify this. Our cruise server has a subversion client (command line) and the .NET 1.1 SDK. Visual Studio isn't installed because, duh, it's a server and cruise just needs something to build the system with.

    Enter Visual Studio 2005. I just recently setup CI for our 2005 projects but it's just plain ugly, in so many ways. First there was trying to get the system to build using MSBuild. That was fine because you can simply enter this:

    msbuild /t:rebuild solutionname.sln

    (or whatever target you want like Debug or Release)

    Like I said, if that's all it was no problem but it gets real ugly real fast.

    First there's VSTS unit test projects. The team is all equipped with Visual Studio Team Suite. An expensive proposition, but one made long ago by someone wiser than me. No problem though. We're not really using the Test Manager much, there are no automated web tests, so we just write unit tests (and run them with Jamie Cansdales excellent TestDriven.NET). However when MSBuild gets ahold of a solution that contains a VS unit test project it needs some additional set of assemblies (assemblies buried in the GAC_MSIL and other places). The snippet in the ccnet.config file to get MSBuild going was pretty straight forward:

    <msbuild>
        <executable>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe</executable>
        <workingDirectory>D:\ccnet\projects\ProjectName</workingDirectory>
        <projectFile>SolutionName.sln</projectFile>
        <buildArgs>/noconsolelogger /p:Configuration=AutomatedBuild /v:diag</buildArgs>
        <targets>Build</targets>
        <timeout>600</timeout>
        <logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
    </msbuild>

    Through brute force (run MSBuild, figure out what assembly it needs, go find it, lather, rinse, repeat) I was able to get a 2005 solution (with unit test projects) to compile. However actually running the tests is another story. Again brute force reigned supreme here as I trodded through an hour or two of running MSTest.exe to try to coax a couple hundred unit tests to run. The cc.config entry for getting some unit tests looks something like this:

    <exec>
        <executable>C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\MSTest.exe</executable>
        <baseDirectory>d:\ccnet\projects\ProjectName</baseDirectory>
        <buildArgs>/testcontainer:Source\Tests\UnitTests\bin\AutomatedBuild\UnitTests.dll /runconfig:localtestrun.Testrunconfig /resultsfile:testResults.trx</buildArgs>
        <buildTimeoutSeconds>600</buildTimeoutSeconds>
    </exec>

    Remember that I said this sever did not have Visual Studio installed. For the VS2005 solutions, I just installed the .NET SDK 2.0 and that was good enough. Although MSTest.exe isn't included, I snagged the file (and it's crazy set of additional DLLs scattered all over the hard drive) from another system and stuck it where the EXE was so it would be happy. 

    No dice on running MSTest against a unit test project. It started down the path of running the test, but then hit a crazy COM error (CLSID not registered) and that was enough for me. No way I'm going to track down all the stupid COM registry settings for Visual Studio 2005. And what the hell was this? COM? I thought we got rid of that about 3 compilers ago?

    So I was stuck to installing a full Team Suite on the server. Okay, I'll bite. I mean, I don't need everything so it'll be okay (I keep telling myself as I watch a million registry entries fill up). A few hours later and I'm staring at my command prompt again and type in my MSTest.exe command. And a dialog box pops up. Yup, a modal dialog box that tells me something is wrong (I don't remember the specifics but it wasn't very informative).

    Visual Studio was installed fine and I could compile and run and build the solution I was trying to, but testing from the command line with MSTest.exe was a no-go. No matter how hard I tried, how much I cleaned up, or how many virgins I sacrificed it just won't go. And there's another problem. With 2003 and our NUnit tests, we go some nice stats. Timings, informative messages, all that good stuff. With MSTest we get nothing (other than x number of tests ran and maybe a failure, but I couldn't get that far to see if it would give the details of the failure). On top of that, the MSBuild logger bites and produces about 10,000 lines of gobbly-gook that isn't very useful. Yes, I could spend my time writing new xslt to make it pretty, trim out the "Everything was okay" lines that fill up the MSBuild task logger but I think that's not value-added at my rates.

    Here's a sample email I got from the build which gives you an idea of how useless a CC.NET/MSBuild/MSTest combo is:

    BUILD SUCCESSFUL
    Project: PROJECTNAME
    Date of build: 12/8/2006 8:08:30 AM
    Running time: 00:00:55
    Integration Request: intervalTrigger triggered a build (ForceBuild)
    Errors (1)
    D:\ccnet\projects\PROJECTNAME\Source\Reports\ServerReports\ServerReports.rptproj (2,1): error MSB4041: The default XML namespace of the project must be the MSBuild XML namespace. If the project is authored in the MSBuild 2003 format, please add xmlns="http://schemas.microsoft.com/developer/msbuild/2003" to the &lt;Project&gt; element. If the project has been authored in the old 1.0 or 1.2 format, please convert it to MSBuild 2003 format.
    Warnings (1)
    Source\Reports\ServerReports\ServerReports.rptproj (,): warning MSB4122: Scanning project dependencies for project "Source\Reports\ServerReports\ServerReports.rptproj" failed. The default XML namespace of the project must be the MSBuild XML namespace. If the project is authored in the MSBuild 2003 format, please add xmlns="http://schemas.microsoft.com/developer/msbuild/2003" to the &lt;Project&gt; element. If the project has been authored in the old 1.0 or 1.2 format, please convert it to MSBuild 2003 format. D:\ccnet\projects\BRMS\Source\Reports\ServerReports\ServerReports.rptproj
    Tests run: 0, Failures: 0, Not run: 0, Time: 0 seconds
    No Tests Run
    This project doesn't have any tests
    Modifications since last build (0)

    It's ugly. Really ugly. MSBuild produces a ton of crazy output. Writing a new MSBuild file is no walk in the park and even for someone like me that knows NAnt quite well, I'm still wrapping my head around how MSBuild does stuff. I had to create a special configuration inside of Visual Studio to omit our Report project because MSBuild can't build them (hence the target AutomatedBuild above which is not the same configuration that our developers use and something I don't like doing because that's one point of a CI server, consistent builds for everyone).

    From the output above, Cruise said the build was okay but there's an error message that came out of the MSBuild logger (our report project). This is a 2005 project so the information makes no sense (I belive it's a bug that's logged but who knows when it might get fixed). And I really can't integrate the MSTest output into the email because, well, there is none. There's a hundred tests or so in this project but the logger doesn't produce anything. 

    Additionaly, there are some project types MSBuild can't handle and again, it takes a rocket scientist to create an MSBuild file (even using something cool like MSBuild Sidekick) that can call another MSBuild task and exclude certain projects. This certainly isn't as easy as it was in 2003 where you just created an exclusion list (we excluded our client app as there was no extra license for the grid control and a modal dialog came up when the trial version was even looked at by the compiler).

    Okay, this is mostly a rant but there's some wisdom here. Continuous Integration does not need to be this hard. CruiseControl.NET is an excellent tool and very flexible with new tools and integrating output from those tools. However when those tools require a million registry settings and even more DLLs (put in very specific places, trust me, you can't just toss them in the GAC and call it a day) and dump gobs of XML that no mere mortal (well maybe DonXml could) would be able to translate, it's just wrong. And as for the built-in Team Build that you could us, that's equally as useless as a) you can't schedule builds to trigger off of code checkins and b) again it requires a full Team Suite client to be installed on the server. Worst case scenario when I first started setting up CC.NET servers it took 4 hours. Now I can get it done in an hour (which includes testing the build of the first project). I've already spent a good day on just trying to get something to compile. It's compiling now but the output is crap and no running of tests and thats just not good enough for me. You can get MSBuild and (maybe) MSTest running with CruiseControl.NET. It's not impossible. If you install the full client and your projects are "just right" it'll work but the output isn't that hot and you'll watch your server CPU slam when compiles happen.

    My advice, avoid trying to combine MSBuild, MSTest, and CruiseControl and stick to NAnt, and NUnit (using MSBuild if you have to when building 2005 solutions).

    Needless to say I'm looking at one option right now. Dumping the install of VS2005 on the server, changing all our unit tests back to NUnit and using NAnt to do everything (and just calling MSBuild as an exec task for VS2005 projects). I still need to run 2003 projects so our CI server is going to look like a Frankenstein monster by the time I'm done, building VS2003 and VS2005 projects, running NUnit, MSBuild, NAnt, Simian, FxCop and whatever else we have in our mix. Even given that, using NAnt the output will be simpler (and integrate well with CC.NET), test output will be useful and informative, and I don't need to install a $15,000 piece of software on a server that has the distinct possibility to pop-up a modal dialog someday when it can't find some registry key.

    Grrr. Argh.

  • Settling in for the holidays

    And finally getting caught up!!!

    Oh man, it's been a roller-coaster ride the past while but I think the worst is over (and the best is yet to come). Vista launches, SharePoint RTMs, new VMs, two sprints completed, new ScrumMaster duties on YAP [yet another project], new laptop, dogs and cats living together... mass hysteria! Tonight I'm finally taking a breather, just to get back on track this weekend with a bunch of stuff like posting crazy entries around everything that's been building in my own backlog.

    A couple of things as I'm sifting through the rubble. I broke down and bought a new laptop. My Presario 4000 was good (it was aimed as a desktop replacement) and a year and a half ago it was. Fast, heavy, but impressive. Most impressive. Now it's all about Core 2 Duo and that so I snagged a Inspiron 9400 from Dell and couldn't be happier. It's an inch larger all around, but half as thin; 3lbs lighter; 100db quieter; and about the same price as I paid for my Compaq. 4-5 days of setting up and installing software and tools and I think it's good to go. I've already given one presentation on using NetTiers and CodeSmith with it (which was a bit of a joke trying to get used to the new keyboard so lots of typo's in the demo).

    Secondly I saw that JetBrains has released their Omea Pro product for free now. I was using the free Reader but now have updated to the Pro. It's everything (mail, rss, newsgroups, tasks, etc.) all in one package and very well done. I gave up on RSS Bandit as it was just chewing up memory like there's no tommorow and Omea lets me flag things say in newsgroup threads so I don't have to read every thread out there. The uber cool thing? They're going open source so we'll get to see how the guys who created ReSharper write code. Very cool learning experience and a very cool tool that will hopefully grow when the community gets its hands on it (I would like to see a WPF version come out of that). Also there's a 2.5 EAP of ReSharper out you can grab, although it's a little buggy (as all EAPs have been with these guys) but looks like it's going to be killer when it releases.

    BTW, if you really only want to subscribe to one blog to find cool (geek) stuff out there check out Jason Haley's Interesting Finds. He's recently (the last month or two) added short comments to the blog entries so it's a great feed to look at and keep on top of cool stuff he finds (most of which I consider cool as well) without having to subscribe to everyone on the planet.