Tags
Automation, AX, AX 2012, AX Build, Build Scripts, Dynamics AX, PowerShell
I’m going to start off with how I set up TFS for a build. I have my main code branch in TFS, D2D_AX_DEV, that is used for all of my development environments. Each AX development environment has TFS setup and pointed to this code branch. I have also set up a branch off of D2D_AX_DEV called D2D_AX_REL. This is my release branch. I merge everything into the release branch that is going to be included in the build. I then point my build function to the release branch.
The Build-AXModel function is broken up into 5 sections:
- Outer section at the beginning and end that set up the variables passed through the parameters and that email start and completion of the function.
- Set up build variables: This section uses variables in the Build-AXModel_Variables.ps1 file that is passed in through the VariablePath parameter to set up the environment for the build and model export.
- Prep build environment: This section restores the AX environment back to a vanilla instance for the build and gets TFS and the combined .xpo file ready.
- Import/Compile AX (Main build step): This section pushes the TFS code into the build environment and compiles/syncs everything and gets the environment ready for a model export.
- Export model: This section exports the model file into your build folders.
The individual steps and explanations for what they are doing can be found in my earlier posts. I have done some things in my Build-AXModel_Variables.ps1 file to make this more of a generic process to be re-used however and I would like to clarify what I’m doing.
There are multiple places in my build function where I loop to allow functions to work on different layers and models (model creation, .xpo creation/import, label file import, VS Project import and model export). In my original process this wasn’t necessary as I only build one model in one layer. The way it is currently built however, allows for multiple layers and models.
I handle this looping process using foreach statements and ArrayLists in my variables. I used ArrayList vs array as the behavior with ArrayLists was a lot more dependable when looping. It is a simple construct. I build variables for the individual parameters needed for a function call. I then build an ArrayList to hold grouped variables for a function call that will allow me to loop through an ArrayList of my grouped ArrayLists and call the function multiple times. My loops are only through the VAR layer and for my D2D model but you can easily add more variables for layers and models to these ArrayLists to allow multiple function calls. Make sure you build your ArrayLists in the order in which you want to process the layers and models.
The area that is most likely to need customization to fit your specific build are the steps in the “Import/Compile AX” region. You may need to change the order of the server/node compiles or change the server compile to a client compile. You may also need to change the function used to import the VS Projects and add some node compiles if you have some complicated dependencies.
As I said in the blog post covering the function, I’m not planning on putting this function into the module because of the likelihood that you will need to modify it to fit your needs. I’m hoping that some users will be able to use it out of the box but I’m sure there are some who will need to make changes. The steps in my version of the function fit the current needs of my build process.