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.
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.
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.
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.
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!