Recently in Dotnet Category

Rock The Build with TFS

| No Comments

If bunnies are just a little bit too cute and fluffy for you, then you might be interested in a little side project that reader Terry Humphries just got in touch with me about.  You see Terry had no love for robotic rabbits in the build process – but an electric guitar was something that he and the other developers in his team would pay attention to. So he hooked up a vintage 1990’s Warlock Electric guitar made by B.C.Rich to TFS and let that rock their world.  I thought this was a cool project so asked permission to share his email with you all. If you want to get in touch with Terry, drop me a line and I’ll send your details on to him.

 

From: Terry Humphries


guitarMy name is Terry Humphries and I work for EnGraph Software. I’ve been a developer for over 25 years the last three months at EnGraph. I came here to join a development team that was scaling up from a couple of developers to over 14 folks. Part of my job has been and continues to be leading EnGraph’s push into using Team System. I spend part of my time wearing a developer hat and part wearing the TFS admin, Build Sensei hat.

Having always been a strong believer in nightly builds and making sure everyone is aware of the status of the build, I’m always looking for ways to get the other developers invested in the status of the build.

Having seen Brain aka the Build Bunny and the Lava Lamp build indicator I decided it was time to create something unique for EnGraph to use.

I almost used a full size traffic light, but since all of the pcs here are named after guitar manufacturers, a Build Guitar seemed the way to go, and the search was on. It took me about three week to locate the used Warlock I used as the basis of the project. I didn’t want a run of the mill guitar, it need to be electric and it needed to have a unique look. When I got the Warlock it’s better years were behind it, the body was in bad shape. I had to end up stripping it, filling in a few dings and refinishing it with a purple undercoat and a bronze metallic pearlized overcoat.

I looked at several options for the switching mechanism for the LEDS. Basically, I wanted something that would provide the low dc power needed to drive the LEDS and a programmable interface for switching them on/off. I considered Ethernet based relays, Bluetooth based relays, Ethernet to parallel port converters, and USB controlled relays. Mostly because the other options were much more costly I settled on the USB controlled relay. I decided to mount this control circuit in its own box and use standard Ethernet cabling to get the power to the guitar from the relay. With this option the only things I had to mount in the guitar were the LEDs, the Ethernet jack, and wire connecting them.

Once I obtained everything I need I started build the controller. Wanting it to also be somewhat different I decided to mount the relay circuit old 3.5 diskette plastic case that was designed to hold 10 diskettes. After mounting the circuit board I added the ethernet jack and connected the power supply. Cut a few hole for the cables and bam the Build Guitar Controller was born.

Next, guitar time. I decided the best place to mount the LEDs was in one of the pickup coil frames, you see a Warlock comes with 2 Humbucker pickup coils each mounted in its own frame. I fashioned a piece of black plastic to fit the frame and drilled three holes for the LEDS. Then I wired the LEDS to the Ethernet jack I had placed in the jackplate.

Then I hooked everything up loaded the Phidgets drivers and using they’re control panel applet tested the wiring and after a few minutes I had everything working as planned.

The folks at Phidgets provide 2 way to interface with their devices, either directly or via a webservice, I used both. I couldn’t find a TFS event that fires when a build starts so I created a custom task that turned on the correct relay and hooked it into our build scripts via the BeforeEndToEndIteration target and then used Howard van Rooijen TFS Event Framework to react to the BuildCompletionEndpoint to set the red and green leds.

The basic code for manipulating the relays is only 9 lines:

InterfaceKit RelayPhidget = new InterfaceKit();

RelayPhidget.open("gibson", 5001);

System.Threading.Thread.Sleep(1000); //wait for the server to connect

RelayPhidget.outputs[0] = false;     //Set build start off

RelayPhidget.outputs[1] = true;      //Set build success on

RelayPhidget.outputs[2] = false;     //Set the other off

RelayPhidget.outputs[3] = false;

RelayPhidget.close();

RelayPhidget = null;

I’m not sure what else I can tell you about it other that it’s a big hit with the other developers. As for more about EnGraph you can visit our web site at www.engraph.com

Hardware:

  • Warlock Electric guitar made by B.C.Rich vintage 1990s
  • 10MM diffused LEDS in Blue, green and red
  • Phidget Interface Kit 0/0/4 available here
  • 5VDC 350milliamp wallwort power supply
  • Various bit of wire, tape glue paint, etc.

Software:

  • Team Foundation Server Notification Event project template from Howard van Rooijen
  • VS2008
  • Phidgets Driver

 

Thanks for sharing this with me Terry, and for allowing me to post your email.  For anyone interested, I’ll be talking more about integrating with Team Foundation Build API’s during my session at Tech·Ed North America 2009 next week.

DTL307 Brian the Build Bunny: Extending Team Foundation Server Build

Fri 5/15 | 9:00 AM-10:15 AM | Room 404

This session digs deep into customization of the Microsoft Visual Studio Team System Team Foundation Server Build system. Learn about the .NET API for Team Foundation Build and how to use it to create your own build status display or even have your team chastised about build failures by a robotic rabbit.

DDD Coming to Belfast

| No Comments

image After the highly successful Developer Developer Developer event in Galway last year, this time it is moving north to my neck of the woods – Belfast. For those not familiar with the DDD events they are run on a Saturday and everyone gets together in this great free event run for the community, by the community.  Session submissions are an open process – and session can be submitted by anyone and the sessions that are held are the ones with most community interest.

There are no Microsoft speakers present, just speakers from the .NET developer community – although I hear on the grapevine that our local Irish DPE’s will be hanging around the crowd to soak up the atmosphere and chat to people that want to the idea behind the get together is that we all get to share in our real world experiences and knowledge from working down at the code face.

Best of all the event is FREE, with all the speakers volunteering and facilities kindly provided by the sponsors.  Not only can you learn about some of the technologies that you would have to pay to go learn about at a TechEd or PDC - the DDD events are a really great way of meeting interested and interesting people locally and making some great contacts.

So – if you are around the area then I encourage you to join me on April 4th in Belfast.  If you fancy giving a talk then head over to the site quick and submit your talk idea now.  Alternatively, if there is a topic that you would love to see covered then suggest it on the site.

Find out more at: http://developerdeveloperdeveloper.com/belfast/

The Year Planner Shuffle

| 1 Comment

2009 Year Planner Today is the first day of the new year in the office and so it is time for me to do the dance that I always do after Auld Lang Syne, and that is the Annual Year Planner Shuffle.  This morning I threw away the 2008 year planner, moved the 2009 one up and printed out a new 2010 sheer.

While I have my Outlook / Google / Apple iCal calendars all synchronized and duplicated onto my mobile devices, I also love to have a simple year planner printed on a sheet of paper and up on the wall next to my desk for quick reference. I have the current year and the following year on my wall and fill it out with key dates as I know about them.  Things like public holidays, conferences, release dates etc.  Anything that I would want to know about when taking a quick look out in the future to do some long term planning.

My favourite year planner comes out of (I think) an Adobe Pagemaker template.  I don’t have Adobe Pagemaker and so at the start a year I will search for “2010 year planner pmd” or whatever the year happens to be and generally I will find a copy of a PDF that some kind soul has published on the internet.  I’ve leached the past few years (since 2007 I think) from some kind person at the University of Wolverhampton.

If you are following my lead and want to fill out a planner for this year then Mary Jo Foley has just published a list of all the Microsoft related events/conferences of 2009.  Many of the items on Mary’s list with the addition EclipseConEclipse 3.5 Release Milestones and the Northern Ireland Public Holidays make up most of the key public dates on my planner for 2009.

Happy New Year to everyone.  What with Visual Studio Team System 2010 development progressing along with Windows 7 and Eclipse 3.5 it promises to be another interesting and busy year ahead.

Often when doing some build integration work with the TFS2008 Build API, you will want to get the latest build for a particular definition – for example to show the latest status of the build etc.  To do that use the following code snippet:

TeamFoundationServer tfs = new TeamFoundationServer("http://tfsserver:8080");
IBuildServer buildServer = (IBuildServer) tfs.GetService(typeof(IBuildServer));

IBuildDetailSpec buildDetailSpec = buildServer.CreateBuildDetailSpec("Team Project", "Build Definition Name");
buildDetailSpec.MaxBuildsPerDefinition = 1;
buildDetailSpec.QueryOrder = BuildQueryOrder.FinishTimeDescending;

IBuildQueryResult results = buildServer.QueryBuilds(buildDetailSpec);
if (results.Failures.Length == 0 && results.Builds.Length == 1)
{
    IBuildDetail buildDetail = results.Builds[0];
    Console.WriteLine("Build: " + buildDetail.BuildNumber);
    Console.WriteLine("Account requesting build “ +
      “(build service user for triggered builds): " + buildDetail.RequestedBy);
    Console.WriteLine("Build triggered by: " + buildDetail.RequestedFor);
}

 

Note that if you are wanting to display a continually updated list of builds, then you should take a look at the CreateQueuedBuildsView method on IBuildServer as a lot of the hard work is done for you.  See my Build Wallboard example on the MSDN Code Gallery for more information.

Live On .NET Rocks...

| No Comments

.NET Rocks The other week Brian Randall and I sat down with Carl and Richard to record a .Net Rocks episode.  Honestly, you wait years for a Brian Randall podcast and then three come along at once!

In this episode we talked about what's been happening in the Team System world since 2005, share some best practice war stories and look forward to some the new goodies coming up in the next release.  You can get the episode here.

Don't forget that if you like listening to podcasts about Team System and Team Foundation Server, then hopefully you'll love Radio TFS :-)

Team Foundation Build API Class Diagram - larger version. As we all know by now - the build system in TFS2008 was substantially improved.  Along with the many improvements came an official API for talking to the build system.  This is the same API that the Team Foundation Build UI in Visual Studio uses, however there are many additional methods that were added that were not for the UI at all but for potential consumers of the Build API.

In talking with folks at community events, and on the MSDN forums I have realized that there isn't a huge awareness of this API.  Having written a parallel implementation of the build API, but in Java for the Teamprise 3.0 release I have spent a great deal of time with the .NET API and have a few examples lying around of how to accomplish certain common tasks - so I thought I would run through a some of them.  If you have an example of something you would like to see with the build API then please leave a comment for this post or drop me a line.

So - let's start with a basic one.  How to queue a build.  This will introduce us to a few concepts with-in the build API that are common across all of the methods.

The Easy Way.

A quick look at the class diagram above will show you that the main interfaces you'll be dealing with in the Build API are the IBuildServer and IBuildDefinition interfaces.  To get started with these you'll need to add references to the Microsoft.TeamFoundation.dll, Microsoft.TeamFoundation.Client.dll and Microsoft.TeamFoundation.Build.Client.dll.

C#

TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer("http://tfsserver:8080");
IBuildServer buildServer = (IBuildServer)tfs.GetService(typeof(IBuildServer));
IBuildDefinition buildDef = buildServer.GetBuildDefinition("TeamProject", "Build Name");
buildServer.QueueBuild(buildDef);

VB.NET

Dim tfs As TeamFoundationServer = TeamFoundationServerFactory.GetServer("http://tfsserver:8080")
Dim buildServer As IBuildServer = DirectCast(tfs.GetService(GetType(IBuildServer)), IBuildServer)
Dim buildDef As IBuildDefinition = buildServer.GetBuildDefinition("TeamProject", "Build Name")
buildServer.QueueBuild(buildDef)

I'm afraid that's the last example you'll be seeing in VB.NET.  Being a Java developer by day I tend to like my semi-colons.  However if you are a VB developer then hopefully you'll be able to follow along as the rest of the examples are more or less just method calls with the occasional bit of casting.

So - what's going on here.  Well we first get hold of a TeamFoundationServer object.  If this was server side code and we wanted to specify some credentials then we would use a slightly difference mechanism but in this case the constructor works well and this will automatically connect using the credentials of the current thread.

Next we get hold of the build service that implements the IBuildServer interface.  Finally we get a hold of the build definition by specifying a team project and build definition name (build definitions are unique per team project in TFS).  We then queue a build using the defaults for that build definition.  This API call is actually shorthand for the following...

The Hard Way

IBuildRequest interface diagram Supposed you want to queue a build, but you don't want to use the default build agent, priority, drop location etc.  Well in that case you need to look at the IBuildRequest interface.  Here you will find all the options to customize the build request, you can specify a build agent, drop location, priority etc like you can do from the Visual Studio UI.  You will also find other options such as being able to queue the build with a maximum acceptable queue position, pass a custom get version for the build or even queue the build in a postponed status.

In the following example, I am going to find a non-default build agent from the server and then queue a build using it.

        TeamFoundationServer tfs = new TeamFoundationServer("http://tfsserver:8080");
        IBuildServer buildServer = (IBuildServer)tfs.GetService(typeof(IBuildServer));

String teamProject = "TeamProject";
String buildDefinitionName = "MyBuildDefinition";
String buildAgentName = "MyBuildAgent";

// Find our (non default) build agent.
IBuildAgentQueryResult queryResult = buildServer.QueryBuildAgents(buildServer.CreateBuildAgentSpec(teamProject, buildAgentName));
if (queryResult.Failures.Length > 0 || queryResult.Agents.Length != 1)
{
throw new Exception("Invalid Build Agent");
}
IBuildAgent buildAgent = queryResult.Agents[0];

IBuildDefinition buildDefinition = buildServer.GetBuildDefinition(teamProject,buildDefinitionName);

// Create a build request based on our chosen definition.
IBuildRequest buildRequest = buildDefinition.CreateBuildRequest();
// Optionally set command line args, drop location, priority, custom source version etc here
// in this case just overriding default build agent.
buildRequest.BuildAgent = buildAgent;

buildServer.QueueBuild(buildRequest);


Pretty simple really and very powerful.  I encourage you to go take a look at the IBuildServer interface to see some of the stuff that you can do.  If you have any suggestions as to what you would like to see as a build API example then leave a comment to this post.

CodePlex Project Stats

| No Comments

The fantastic team at CodePlex have just rolled out yet another great feature - this time it is statistics for your CodePlex project.  I dropped by my TFS Plug-in for CruiseControl.NET to take a look...

codeplex_stats 

The project is currently averaging over 12 downloads a day and has had nearly 5000 downloads since I moved it to CodePlex in August 2006.  Not bad for a chunk of code I originally wrote on a plane..

This is incredibly motivating as a maintainer of an Open Source project.  I've been knowing that I need to give the CC.NET integration some love as there are a few issues and things that I need to address from the excellent feedback I have been receiving.  However - seeing how many people are still interested in the plug-in despite the excellent CI functionality in the 2008 release of TFS has made me realise that I need to get on this ASAP.  Thanks CodePlex!

Archives

Creative Commons License
This blog is licensed under a Creative Commons License.