2 minute read

Background

A couple of days ago I was upgrading some of my clients MSBuild tasks to WorkFlow Activities following the Rewrite MSBuild task as a Workflow Activity option in the guidelines from this excellent post “Upgrade Paths for Custom MSBuild Tasks” by William Bartholomew.

I stumbled upon a custom Assembly Versioning MSBuild task and I took a moment of thought to see what I could do to improve this MSBuild task. I read this great post “Versioning Code in TFS – Revised” by Mike Fourie’s and yet another great post “TFS 2010 Build Number and Assembly File Versions: Completely In Sync with Only MSBuild 4.0” by John Robbins that I really encourage anyone doing custom versioning in TFS 2010 to read.

I decided to follow some of the posts recommendations and decided that for the purposes of my client I would not need to convert this (former) MSBuild task into a coded CodeActivity because a designed activity would be more then enough.

Anyway a simplified version of the clients workflow activity looked something like this:
image

With some input arguments that looked like this:

image

Everything is pretty straightforward if you’re custom to TFS Build and Windows Workflow Foundation except for the Activites in the Then/Else sections. In the Then/Else sections I’m using the AssemblyInfo Activity from Community TFS Build Extension.

Challenge

So I check-in my custom assembly and make sure that the controller is pointing to the folder in the source control tree that contains my custom assemblies.
image

I then added my new Activity to the build process template and ran my first build against that build process template…BOOOOOM! Got this message:

TF215097: An error occurred while initializing a build for build definition \Tailspin Toys\HugoHaggmark: Cannot create unknown type '{clr-namespace:HugoHaggmark.TfsBuild.Activities}Example'.

image

Solution

Are you in the same situation as me? Don’t despair a simple solution is close. Ler

  1. Firstly open up build process template as XML.
  2. Find the reference to your Custom Activity in the XML (probably in the top section of the XML), looks something like this:

    xmlns:local="clr-namespace:<YourNameSpace>"
    

    or in my case I had this:

    xmlns:local="clr-namespace:HugoHaggmark.TfsBuild.Activities"
    
  3. Add ;assembly= to that reference so in my case the end result looked like this:

    xmlns:local="clr-namespace:HugoHaggmark.TfsBuild.Activities;assembly=HugoHaggmark.TfsBuild.Activities"
    
  4. Create a partial class right next to your Custom Activity and add the BuildActivity attribute like shown below:
    image
  5. Check In, rebuild and redeploy assemblies to the custom assemblies folder.
  6. Run the build and voila! The build error is gone!

Cheers,

Hugo

Comments