Wednesday, July 23, 2014

VS 2012 and TFS 2013 Build Process Templates - How to add DefaultTemplate.11.1.xaml

Today was one of those days that forced me to blog. It was a deeply frustrating day but ended on a high and I thought to myself why hasn't anyone blogged that before?

I have a VS 2012 solution that was held in TFS 2012 and I've now moved it to TFS 2013.  I did not want to upgrade the development team to VS 2013 just at this moment. Besides, I thought VS 2012 and TFS 2013 were compatible, right?  I was trying to set up automated builds so I created a Build Controller on my build server using the TFS 2013 DVD image.

I opened my solution and selected create Build Definition and selected the Default Template (TfvcTemplate.12.xaml). I immediately saw lots of errors and a few minutes Googling revealed that you can't use this TFS 2013 template for VS 2012 projects.

Now the link just below the drop down list of build process templates should direct you to where the templates are stored in Source Code Explorer. Now my link showed #/1/BuildProcessTemplates/TfvcTemplate.12.xaml and that navigated to nowhere. I mean the link doesn't even start with $ so how was that ever going to work?

So I started trying to find the XAML files for the Build Process Template that the Build Controller was using. If they weren't in TFS then presumably they were on the hard drive. No. Then how do I add a Build Process template to the list? Hours of searching revealed nothing and this was the deeply frustrating part of the day.

Then I found this blog. The author very kindly provides the source code to create a Console application that will allow you to list the Build Process Templates you have and crucially to add a new one.  BTW, the two references that you need to add for this to work can be found in the GAC (C:\Windows\assembly\GAC_MSIL)

Now I already had the DefaultTemplate.11.1.xaml file that I needed for my VS 2012 solution because it was sitting there in the BuildProcessTemplates directory beneath the root of my project in TFS. 

I used the command line similar to this:

ManageBuildTemplates.exe http://jpricket-test:8080/tfs/TestCollection0 TestProject add  $/TestProject/BuildProcessTemplates/MyTemplate.xaml

to add my Build Process Template.  As soon as I selected a new Build Definition I could see my newly added template and I was cooking.  A few minutes later I had my first successful automated build.  From the depths of despair to deep joy in just a few minutes. 

Which of course made me think - why hasn't anybody blogged this before? And Microsoft what the hell were you thinking? Why isn't this essential tool included with TFS?  Thanks again Jason Prickett for providing the source.


Unknown said...

I'm trying to do something similar, but 'backwards' - in that my team's TFS version (update 2) is older than the installation of my test-environment (update 3) I have running on a virtual-machine accessed by remote desktop.

I want to use 'captured' CodedUItests on webpages taken with Visual Studio 2013, to have a 'front-end' of Microsoft Test Manager in order to select and report test runs.

It seems its the default template that gives me an issue, as the 'newer' is on my test-environment, and the older on the team TFS. The TFS end cannot be updated right now, due to the amount of work going on.

Any idea how I would replace Update 3 template on the test-side, with update 2? I can't seem to find the file anywhere.

blogswamp said...

Hi Charles,

I am facing an issue similar to this one ...

Looks like similar question but unanswered ...,+build+by+label,+build+process+template+not+found+in+source+control+at+version

I am able to build by label via builddefinition but not through "tfsbuild start" command which i am triggering vai jenkins unless i add the buildprocesstemplate to the label any idea why that is the case...

I am going crazy with this ... sorry .pointers pls