I'm Joris "Interface" de Gruyter. Welcome To My

Code Crib

TFS Build Workflow

Jun 1, 2011
Filed under: #daxmusings #bizapps

This will be a rather lengthy post. I’ve received several emails asking how to implement the TFS build scripts. Well, it’s pretty easy actually.

First things first. The build scripts need to be available to your build agent, of course. To that end, you can either put them in a fixed location and call them from that fixed path. However, at Streamline Systems we actually sometimes switch between building on a dedicated build VM (per client - to support different versions of AX) to building on an AOS server where consultants can remote in to test. To support our multiple scenarios, we actually put the build scripts IN the source tree, so that the build script workflow can run it, regardless of what server or where the scripts are located. They’re always in the source’s root. The added benefit is you’re versioning your build scripts, in case you need something crazy for a particular project/branch.

Anyway, the following is a TFS project based on the CMMI template. I’m unsure if the Agile template has a different build template. I’m assuming it’s slightly different, except for these essentials steps, regardless of your project management style.

First, locate the spot in the XAML (have fun scrolling) where it actually does the compiling. I’ve noticed there’s more than one MSBuild statement in there, so locate this exact spot.

<img style=”float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 180px; height: 200px;” src=”http://4.bp.blogspot.com/-3I5fjsF5zdY/TeWibf-TrqI/AAAAAAAAA1Q/q5dbYlAXxO8/s200/TFS-WF-01.png” border=”0” alt=”“id=”BLOGGER_PHOTO_ID_5613071103910194850” />

Now, we want to get rid of the MSBuild task (delete!) and add the calls to our build scripts instead. To get the console output, errors and warnings to show up in the logs, we need to capture the output. So, to that end, add a step (where the MSBuild used to be) and add the “InvokeProcess” workflow step. In fact, add two while you’re at it. Now, as you may have noticed, the build scripts have some optional parameters. The cool thing with TFS is, you can create “arguments”. That way, even if you don’t use the optional parameters NOW, you can still use them later. Also, we’ll use arguments to make the AX configuration file a parameter to the build script. As for the standard and error output, you can have it write to the actual output, and then use them to write as build output / build errors. Completed, it should look something like this.

<img style=”float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 200px; height: 170px;” src=”http://2.bp.blogspot.com/-CfQ1UVgrBS8/TeWnTo8wFdI/AAAAAAAAA1Y/lI_YYPGe2j8/s200/TFS-WF-02.png” border=”0” alt=”“id=”BLOGGER_PHOTO_ID_5613076466438772178” /><img style=”float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 200px; height: 93px;” src=”http://4.bp.blogspot.com/-JpxN_sp8gHw/TeWoCPs8e8I/AAAAAAAAA1g/DageYLFlExE/s200/TFS-WF-03.png” border=”0” alt=”“id=”BLOGGER_PHOTO_ID_5613077267115441090” />

As you can tell, the process you invoke, should be “powershell.exe”. We use the SourcesDirectory as the working directory, since that is where our build scripts will be located (TFS will pull them from the source tree, along with the XPOs). As for the arguments, we pass in the main build script name along with the properties.

<img style=”display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 200px; height: 10px;” src=”http://4.bp.blogspot.com/-EtN5TpayzAQ/TeWpXSF31qI/AAAAAAAAA1o/8KD3b1ayKNY/s200/TFS-WF-04.png” border=”0” alt=”“id=”BLOGGER_PHOTO_ID_5613078728045745826” />

You can see we added an “argument” for the config file which you can then use in the parameters to the build script. As for the second InvokeProcess step you’ve added, that is used to get the compiler errors and warnings. Same setup for the workflow step, except this time, write the standard output to the writebuildwarning, and error output you write to writebuilderror.

<img style=”display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 200px; height: 15px;” src=”http://1.bp.blogspot.com/-0QrUIhd2FWk/TeWqvLIpawI/AAAAAAAAA1w/3QJOmEgil_g/s200/TFS-WF-05.png” border=”0” alt=”“id=”BLOGGER_PHOTO_ID_5613080238006823682” />

Now you setup the build definition; you will need a blank solution file… you don’t need anything in it. I’m sure you can find it in the workflow where it looks for it (and remove that step), but we never bothered.

I hope this will get you started with the scripts. Let me know how it works out for you!

 

There is no comment section here, but I would love to hear your thoughts! Get in touch!

Blog Links

Blog Post Collections

Recent Posts