Friday, March 6, 2009

Setting up local developers with CCTray

In my last post I talked about creating a Continuous Integration server and talked about some of the advantages it provides.  Another useful tool that can be used with CruiseControl is CCTray.  This handy little control places an icon in your Windows tasks tray which is Green when all is well, yellow when a build is in progress and Red if a build has failed.  Placing this on all developers machines provides visibility when an error occurs in the build and ensures that all problems are addressed swiftly.

Installing CCTray

Download the software CruiseControl.NET-CCTray from the SourceForge site and run the setup executable.

image

Click Next and “I Agree” to the licence agreement.

image

Take all the default components and click Next.

image

Select the installation folder and click Next and click Install.

image

Installation should complete successfully and produce no errors, click “Next” and then “Finished”.  CCTray should appear automatically. on your screen.

image 

Configure CCTray to communicate with the server

Once CCTray has been installed you need to select the projects and server on which you want to be notified.

image

Choose File/Settings and tick “Show in Taskbar” then click the “Build Projects Tab”.

image

On this tab click “Add”, then “Add Server” and on the build server tab select “Connect directly using .NET remoting”. Note: there are other options should you want to work externally, however in this case everything was working on a LAN.  Enter the server name and Click OK.

image

Once the server has been validated, it should appear on the left hand side and a list of all valid projects appear on the right.  Select one or more of the projects you want to monitor and press OK.  Once back at the settings dialogue click OK once more.

image

Now you will be able to see anytime a build has completed by viewing the CC icon in your task tray.

image

Wednesday, March 4, 2009

Building a Continuous Integration Server

Continuous integration refers to the practice of frequently integrating developers code with the code that is already released.  It has a number of advantages for a small development team in that:

  1. All check-in are checked against the existing code base
  2. It allows for additional checks such as Unit Tests, code compliance and others to be run automatically.
  3. It provides developers in the team with instant feedback when errors occur on any application.
  4. It assists in the release of applications as everything is packaged on the build server and scripted correctly.
  5. As builds are taken only from a source control database, it ensures that all information and scripts have been stored before an application can be released.

Installation on the server

To run a continuous integration build server you need the following applications installed.

Windows 2003 Server R2
IIS
Visual Studio 2008
Source Safe Client
.Net Framework 3.5
Cruise Control.net
CCNetConfig

Assuming that the server has been built using the standards set down the additional tools are installed as follows:

CruiseControl.Net

Run the executable that is downloaded from SourceForge.

image

Click “Next”, click “I Agree” to the licence agreement and Next selecting all default components.

image

Select both options and click Next.

image

Set the destination folder and click Next and finally click “Install”

image

Once installation has completed click “Next” and click Finished.

CruiseControl.Net

Run the executable that is downloaded from CodePlex.

 image

Click Next and accept the licence agreement and click “Next”.

image

Set the destination folder and click “Next” and finally click “Install”.

image

Once installation have completed click “Finish”.

Configuration of the build projects

Each application should have it’s own project within the CruiseControl.Net application.  Each project is basically a set of tasks which are described using XML and stored in the CCNet Server Configuration file.  These files can get quite long and complicated, which is the reason we use the CCNetConfig application which provides a simple point and click interface.

Open the CCNet Config application, using Start/All Programs CCNet Config/CCNetConfig.

image

When the application starts choose file/Open from the menu and browse to the location of the CruiseControl directory.  Within the server folder you’ll find a file called ccnet.config, select this file and set the version combo box to the version of CruseControl you are using.  In this case it was 1.4 and click “Open”.

image

Assuming you’re starting for the first time you will only see two entries in the tree, select the first “CruiseControl” and click the first icon in the tool bar to create a project.  You will see a dialogue appear, in which you enter a meaning name for the project you’re trying to place in continuous integration.  In this case I’m using “Debug – CryRptCom” which is a debug build of a small Visual Studio 2008 project.  Click OK and the entry should appear in the tree on the left.

image

Once the project is created expand the tree node and the select Tasks node and fill in the required information such as the working directory for the project, account to access SrouceControl, etc. 

Note: Create a folder named “buildlogs” folder in the working directory selected or the build will fail.

Once that has been completed right click the Triggers node and and select “Add Trigger/IntervilTrigger”.

image

Enter the information needed to trigger a build, in this case If a change exists in source Control and wait 120 seconds before testing for the next change.

Once that has been completed right click the Tasks node and and select “Add Task/Visual Studio Task”.

image

Enter the information needed to build the code Using Visual Studio 2008.

Starting the CruiseControl Service

Once the project has been configured you need to start (or restart)  the CuriseContorl service in order for the changes to be read.

image

From the Control Panel/Administrative Tools, select Services and select the CruiseControl.Net, then click the Start icon on the tool bar.  the Service should start without any errors.

 

Accessing Cruise Control from a developers client

The Cruise Control application creates a website by default which is used to interacted with the client application.  In this case the development server URL is http://miranda/CCnet/

image 

You should see the project you have entered into the configuration screen.  Now you can click the “Force” button to build the application on the server.  This will get the latest version of the application from source control, download it to the server and build everything.  If it passes all the test correctly it will show a green “Success” message in the last build status column.

image

The process is also running continually, so if any developer tries to check in code which does not compile for example as I did here be commenting out a sting.

image

After a few seconds the CruiseControl will report the error.

image image

Click on the project link to get the error message… and as you can see “rgreene” was the last person to access the files and you also see the comment used for the check-in.  After fixing the error and checking in you will see that the project goes back to green status.

Wednesday, February 25, 2009

Unrecognized attribute 'xmlns'.

If you ever the the error message “Unrecognized attribute 'xmlns'.” appear in the browser.

image

the reason is because the .NET framework is set to version 1.1 and not 2.0.  To fix this open IIS and right click the virtual directory, in this case CSSSearch and select Properties from the menu.

image

Click the ASP.NET tab and change the ASP.NET version to 2.0.

image

Click OK and that should be it.

Sunday, February 22, 2009

Linq extensions missing

I recently had a project to do using the new Microsoft Entity Framework, which gave me a serious bit of head scratching to do. The problem was that I had created a model as usual and created a controller class as usual; however compiling the code below gave me the error:

'System.Data.Objects.ObjectQuery' does not contain a definition for 'ToList' and no extension method 'ToList' accepting a first argument of type 'System.Data.Objects.ObjectQuery' could be found (are you missing a using directive or an assembly reference?)


public object GetSuppliers()
{
ObjectQuery supplierQuery;
using(NorthwindEntities northwindContext = new NorthwindEntities())
{
supplierQuery = northwindContext.Suppliers;
}
return supplierQuery.ToList();
}


WTF? Hang on I've used code like this dozens of times before and never got this error before. It took quite a time for me to figure out that when the class was created by Visual Studio it had failed to add the usual using System.Linq; line at the top.

This lead me to think, why this was the case and I found this interesting article which describes extension methods.

Simple once you know the answer.

Thursday, February 19, 2009

Adding the Firebug plug-in to FireFox

I love firebug, I’d go as far as saying the main reason you’d want to download the browser to use use this fantastic little bit of functionality.  This handy little tool allows for the debugging, editing, and monitoring of any website's CSS, HTML or JavaScript.  It’s also very handy for working with JQuery.

Adding Firebug to your browser

First you need a copy of Firefox which you can get from the web.  (Note: you should be on FireFox v3 or higher to use FireBug)

image

Once you’ve started Firefox go to Tools/Add-ins from the menu.

image

Click “Get Add-on” in the upper left hand corner and type “FireBug” into the search field below and hit Enter..

image

Firebug should be the first one returned.  Click the “add to Firefox” button

image

Click the Install Now button and close the Add-In window and restart FireFox.

image

Now you should be able to see the Firebug logo in the bottom right Hand corner, click this at any time to start the Add-in.

Using Fire Bug to view HTML and run Scripts.

On any webpage click the bug icon.

image

A window will appear below showing all the HTML on that page which can be easily navigated.

To run a script click on the Console tab.

image

Click on the Console box and hit the “Apply settings to <server name>”

image

You will need to expand the Console window by clicking the red arrow in the bottom left hand corner.

Enter your script into this box and click Run.

e.g.  Before

image

after hitting Run.

image

As you can see the word “Hello” has been added to the DIV named “theDiv”.  The left hand side of the screen returns the results or any errors encountered on that JQuery script.

Monday, February 16, 2009

SharePoint MOSS won’t let you do a ‘Complete’ installation

If after attempting to install SharePoint Moss you get the following issue where it will no allow you to choose a “Complete” installation.

image

This problem is not due to MOSS itself but to WSS version 3 which is a required pre-requisite.  When installing WSS the User probably chose the “basic” installation option.

Removing WSS version 3 and re-installing.

Unfortunately there is no simple way to change the installation once it has been created so you need to remove the old version and reinstall.

image

From the Control Panel chose Add/Remove Programs and choose “Microsoft Windows SharePoint Service 3.0” and click the Remove button. Click “Yes” to confirm you with to remove the program.

image

You will get a warning message regarding any existing data you may have in SharePoint, Click OK.

image

Eventually the uninstall will complete, click Yes and allow the server to reboot.

Run the installation for WSS version 3 again which can be downloaded directly from Microsoft.

image

You should see the progress bar.

image

Accept the Licence Agreement and click Continue, when the message dialogue appears.

image

Choose “Advanced”.

image

Choose “Web Front End” and click “Install Now”.

image

Unclick the “Run the SharePoint Products and Technology Configuration Wizard now” option and click “Close”.

Now when you run the MOSS installation you should see the following:image

Now you get the option to install MOSS as a “Complete”.