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 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 by Mike Fourie’s and yet another great post 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:
With some input arguments that looked like this:
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 here.
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.
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’.
Solution
Are you in the same situation as me? Don’t despair a simple solution is close.
- Firstly open up build process template as XML.
- 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”. - Add ;assembly=<Name of your 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” - Create a partial class right next to your Custom Activity and add the BuildActivity attribute like shown below:
- Check In, rebuild and redeploy assemblies to the custom assemblies folder.
- Run the build and voila! The build error is gone!
Cheers,
Hugo
Solved my problem, thanks Hugo! 🙂
Glad it helped you!
This is really great ! Thanks!!
Hello,
I am getting a same error, while I am importing a Powershell Workflow activity into toolbox. Its imported successfully but while executing it gives the below error.
TF215097: An error occurred while initializing a build for build definition Exception Message: Cannot create unknown type ‘{clr-namespace:StopService;assembly=StopService}StopService’. (type XamlObjectWriterException)Exception Stack Trace:
The Activities has been created by using the steps in http://msdn.microsoft.com/en-us/library/hh852743(v=vs.85).aspx
The DLL is created and successfully imported into workflow toolbox, but while using it in a build its giving the above error.
Hi,
I’m not sure what I can do to help you out.
Are you saying you still have the same issue after you’ve followed the steps in my post?
Yes I am still getting the error.. 🙁
I’m also still stuck on this error. I have added the assembly to the namespace and already had the correct BuildActivity attribute. I’ve also tried other suggestions, like make sure the custom-activity project is build for Platform ‘Any CPU’; but it already was.
The custom assembly does show up in the temporary assemblies folders of the build-controller & -agent, but I still get the error.
As soon as I add the assembly to the GAC, the build works. So that’s my solution for now. But I’d really like to know why it’s not working from source control. I want to add unit test adapters (for xUnit and the like) to the build-servers later, which I would like to do through version control.
Any suggestions are highly appreciated…
Sorry but I have no other suggestions.
You’re awesome! Thank’s!
Thank you
Just a tip for anyone else running into this and getting stuck: If you make changes to your build activities assemblies, you may need to restart the build controller service to pick up the changes.
The partial class example was something that I could have never figured it out myself. Nail in the head!
How did you get there?
Hi and thanks!
How does anyone get a solution to any problem?
Hard work I guess in this case but I’m not entirely sure as this was almost 3 years ago.
I hope the TFS-team already solved this bug.
Apparently not, as I have just been bitten by the bug.
Thanks very much, Hugo, you saved me a lot of time!
Thanx for the feedback, glad it helped.