Updated 30th Aug 2012: This post is specific to TFS/VS 2012 RC - for details on the RTM see this updated post

Whilst moving over to our new TFS2012 system I have been editing build templates, pulling the best bits from the selection of templates we used in 2010 into one master build process to be used for most future projects. Doing this I have hit a couple of problems, turns out the cure is the same for both

Problem 1 : When adding custom activities to the toolbox Visual Studio crashes

See the community activities documentation for the process to add a items to the toolbox, when you get to step to browse for the custom assembly you get a crash.

clip_image002

Problem 2: When editing a process template in any way the process is corrupted and the build fails

When the build runs you get the error (amongst others)

The build process failed validation. Details:
Validation Error: The private implementation of activity ‘1: DynamicActivity’ has the following validation error:   Compiler error(s) encountered processing expression “BuildDetail.BuildNumber”.
Type ‘IBuildDetail’ is not defined.

image

The Solution

Turns out the issue that caused both these problems was that the Visual Studio class library project I was using to host the XAML workflow for editing was targeting .NET 4.5, the default for VS2012. I changed the project to target .NET 4.0, rolled back the XAML file back to an unedited version and reapplied my changes and all was OK.

Yes I know it is strange, as you never build the containing project, but the targeted .NET version is passed around VS for building lists and the like, hence the problem.