Edit & Compile Team Foundation Server 2012 (TFS2012) Builds with Custom Build Activities

August 24, 2012

So, you’ve all downloaded and installed your copy of Team Foundation Server 2012 and Visual Studio 2012, right?  Of course you’re migrated all your code and servers over to TFS2012 and VS2012, right?  (Answer: heck yes! We’ve been running it in production since the Alphas!)  NICE!

Anyway…I’ve been doing some TFS2012 build customization work lately and working on porting my custom TFS build activities to .NET 4.5 and all the latest and greatest.  When I’m editing a custom XAML build script with custom activities in it, I find that it’s helpful to be able to compile my build scripts before I check them in to TFS so that I can hopefully make sure that they’re error-free.

The way that I do this is to create a Workflow Console Application (Figure 1) and then add my TFS2012 Build Script (*.xaml) to this project (Figure 2).

(Feeling lazy?  You can skip these steps and just download my project.)

SNAGHTMLaf4e9f

Figure 1 – Create a Workflow Console Application

SNAGHTMLb0b7fc
Figure 2 – The Team Foundation Server 2012 XAML Build Script in the project

When I first add the build script to the new project, I’ll get a zillion compile errors because the script makes a lot of references to assemblies and none of these assemblies have been added to the References for the project yet.

Here are the references that need to be added to your project and where to find them:

  • C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PrivateAssemblies

    • Microsoft.TeamFoundation.TestImpact.BuildIntegration.dll
    • Microsoft.VisualStudio.TeamFoundation.dll
  • C:\Windows\assembly\GAC_MSIL\Microsoft.TeamFoundation.TestImpact.Client\11.0.0.0__b03f5f7f11d50a3a\

    • Microsoft.TeamFoundation.TestImpact.Client.dll
  • C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ReferenceAssemblies\v2.0

    • Microsoft.TeamFoundation.Build.Client.dll

    • Microsoft.TeamFoundation.Build.Workflow.dll

    • Microsoft.TeamFoundation.Common.dll

    • Microsoft.TeamFoundation.VersionControl.Client.dll

    • Microsoft.TeamFoundation.VersionControl.Common.dll

    • Microsoft.TeamFoundation.WorkItemTracking.Client.dll

  • Assembly References

    • System.Activities.Presentation
    • System.Drawing
    • PresentationCore
    • PresentationFramework
    • WindowsBase

Once you add these references to the project, you can then modify the XAML script through the designer and then run Build Project to verify that it doesn’t have any compile errors.

SNAGHTMLb4a805
Figure 3 – Editing the TFS2012 Build script in the XAML designer

Want that project?  Download

I hope this helps.

-Ben

-- Looking for help getting rolling with Team Foundation Server 2012?  Need some pointers on how to customize your TFS2012 Builds?  Want to move your Scrum or Agile project management tasks in to Visual Studio 2012 and TFS2012?  Drop us a line at info@benday.com.

Tags: team-build tfs