• About

Day 2 Day Dynamics

~ Experiences of a working AX developer

Day 2 Day Dynamics

Tag Archives: AX Build

Understanding the Build-AXModel function

08 Thursday Oct 2015

Posted by John Hagler in Powershell

≈ Leave a comment

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:

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.

ArrayListEx

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.

Build-AXModel custom PowerShell function

23 Wednesday Sep 2015

Posted by John Hagler in Powershell

≈ Leave a comment

Tags

Automation, AX, AX 2012, AX Artifacts, AX Build, AX Deployment, AX Import, AX Label, Build Scripts, CIL, Compile, Dynamics AX, IL, PowerShell, R2 CU7, Synchronize

I apologize for the extra week between posts.  It has been a lot of work to get this function ready to post.  I built the D2DDynamics PowerShell module using cleaned up functions that were based off of the original functions I used to create my build.  Even though I tested all of the functions as I built them, my actual build was still using my old functions.  Getting my new build ready required me to bring my module into my build environment and re-write and re-test my build.  I also wanted to get at least one build done in my environment using the new function before posting it.  Hence, the extra week.

I’m not going to get too in depth regarding the function this week.  I am making it available so people can look at it and try and get an idea of what I’m doing.  I will be covering the specifics of it in future posts.  Also, I will not be including it in the module.  It is possible that a large percentage of users will be able to use the function as-is to create a build but some users will need to modify it to make it work for them and all users will need to modify the variables.  You should add the function to your session using your profile.

I have also updated the D2DDynamics module to version 1.0.1.  This release includes some documentation changes, a new Comment parameter for the Sync-AXTFSWorkingFolder function and I’ve exposed the Send-Email function because I use it in the Build-AXModel function that isn’t part of the module.  To use the Build-AXModel function, you will need to download and setup the latest version of the module (1.0.1).

The Build-AXModel custom PowerShell function takes 3 parameters:

  • BuildNumber (The build identifier)
  • ConfigPath (Client configuration for the AX build environment)
  • VariablePath (Path to a file used to default the parameters/variables)

All 3 variables should be used, although you could specify the ConfigPath in the Variable path file if you’d like.  I have defaulted both values in the function that I use already to make my life simpler.  Feel free to do the same thing in the function that you use.  This function is not designed to be used “out-of-the-box”.  You can customize the defaults and you will need to customize the Build-AXModel_Variables file that is used for the VariablePath parameter for this function to work.  I will get into what/why/how to use the variables in a later post.  For now you can look at the 2 files (Function_Build-AXModel.ps1 and Build-AXModel_Variables.ps1) and get an idea for what is going on.

There are 15 basic steps to the build:

  1. Sync TFS and set the label using Sync-AXTFSWorkingFolder
  2. Stop the AOS
  3. Restore the build environment to vanilla using Restore-AXDatabase
  4. Create the new models
  5. Delete the old artifacts using Clean-AXArtifacts
  6. Start the AOS (Build environment is now clean and ready for the new build)
  7. Generate the combined .xpo files using Combine-AXXPO
  8. Import label files using Import-AXLabelFile
  9. Load the combined .xpo files using Import-AXXPO
  10. Compile and load the VS projects using Start-AXMSBuildImport
  11. Compile the AOT using Start-AXBuildCompile and Compile-AXXppNode
  12. Compile CIL using Compile-AXCIL
  13. Sync the data dictionary using Sync-AXDB
  14. Reload the AX artifacts using Clean-AXArtifacts (This step helps with label file issues when pushing the model)
  15. Export the model file
Follow Day 2 Day Dynamics on WordPress.com

Day 2 Day Dynamics

  • RSS - Posts
  • RSS - Comments

Follow me on Twitter

My Tweets

Recent Posts

  • Minimizing Database Calls
  • Push-AXModel custom PowerShell function
  • Clean-AXModel custom PowerShell function
  • Get-AXTFSCombinedXpo custom PowerShell Function
  • Refresh-AXAifPort custom PowerShell function

Archives

  • February 2016
  • December 2015
  • November 2015
  • October 2015
  • September 2015
  • August 2015
  • July 2015
  • June 2015
  • May 2015
  • April 2015
  • March 2015
  • February 2015

John Hagler

John Hagler

John Hagler

I am the Dynamics AX Technical Architect at Dealer.com. I have been working with AX since Sep. 2006, starting with Axapta 3.0. I have worked as both a VAR and an AX customer.

View Full Profile →

Blog at WordPress.com.

  • Follow Following
    • Day 2 Day Dynamics
    • Already have a WordPress.com account? Log in now.
    • Day 2 Day Dynamics
    • Customize
    • Follow Following
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar
 

Loading Comments...