• About

Day 2 Day Dynamics

~ Experiences of a working AX developer

Day 2 Day Dynamics

Tag Archives: AX Label

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

D2DDynamics custom PowerShell module

31 Monday Aug 2015

Posted by John Hagler in Powershell

≈ Leave a comment

Tags

ALD, AOT, Automation, AX, AX 2012, AX Artifacts, AX Database, AX Import, AX Label, Build Scripts, Compile, DB, Dynamics AX, PowerShell, PowerShell Module, R2 CU7, Server Compile, Team Foundation Server, TFS, XPO

The D2DDynamics custom PowerShell module is finally available in Codeplex.  The 1.0.0 version includes 15 exportable PowerShell functions and 3 internal helper functions.  They are:

  • Get-AXAutoRunXML
  • Start-AXAutoRun
  • Start-AXBuildCompile
  • Compile-AXCIL
  • Sync-AXDB
  • Compile-AXAOT
  • Clean-AXArtifacts
  • Import-AXXPO
  • Import-AXLabelFile
  • Sync-TFSWorkingFolder
  • Restore-AXDatabase
  • Combine-AXXPO
  • Start-AXMSBuildImport
  • Compile-AXXppNode
  • Import-AXVSProject

The 3 internal functions are:

  • Send-Email
  • Clean-Folder
  • Clean-Folders

This module is dependent on the 0.3.5 release of the DynamicsAXCommunity PowerShell module among others.  There are also some variables that should be set up in your profile if you are planning on using the functions.  The profile that I use can be found in Codeplex at Source Code -> Powershell -> Profile -> Modules -> Microsoft.PowerShell_profile.ps1.  Please use this as a reference for setting up your own profile.

To install the module, copy the D2DDynamics folder to the module folder for PowerShell.  On my Server 2012 server, the location is “C:\Windows\System32\WindowsPowerShell\v1.0\Modules”.  After the module is there, you should be able to open PowerShell and add it with the Import-Module cmdlet.

Future posts will include the steps necessary to create a custom build process using the module as well as more functions that can be used for deploying your build to other environments.  Please let me know what you think of the module and if you find any problems with using the functions in your environments.

Import-AXLabelFile custom PowerShell function

21 Thursday May 2015

Posted by John Hagler in Powershell

≈ 2 Comments

Tags

ALD, ALDImport, Automation, AX, AX 2012, AX Import, AX Label, Build Scripts, Dynamics AX, PowerShell

The Import-AXLabelFile PowerShell function allows you to import an AX label file into an environment.  While getting this function ready for the post, I realized that I had made a mistake in an earlier post.  My current build process was built to handle one layer and one model.  That was all I needed at the time and I had a limited amount of time to get it up and running.  It was always my plan to make this more generic however and to do that I needed to make my functions and build process able to work for multiple layers and models.  This required a few changes.

I needed a way to support what model is opened in AX for both this function and the Import-AXXPO function.  I have done that using the Model parameter.  Using the ConfigFile parameter to control layer and the Model file to control the model in that layer, individual calls have the ability to control the startup model versus using the “Startup model” system parameter that I had been using.  I have updated both the Start-AXAutoRun and Import-AXXPO functions to support this parameter as well as the blog posts regarding these functions.

The Start-AXAutoRun function takes between 5 and 8 parameters

  • ConfigPath (Client configuration for the chosen AX environment)
  • Model (The AX model to open in)
  • LabelFile (The label file to import)
  • Timeout (The value defaults to 10 minutes but can be overridden if desired)
  • SMTPServer (SMTP server to use to send the email)
  • MailMsg (Net.Mail.MailMessage object used to send the email)
  • AXVersion (The AX version.  It defaults to 6.)
  • VariablePath (Path to a file used to default the parameters/variables)

This function can be found in Codeplex.  The steps of this function are:

  • Load the variables if a VariablePath parameter is used
  • Validate the LabelFile parameter location
  • Start the AX client using the aldimport startup command
  • Wait for the timeout period for the AX client to exit
  • Send the success/fail message

This function is extremely similar to the Start-AXAutoRun function.  There are multiple commands to use to start AX and while AutoRun can do multiple things, it can’t import label files.  It is possible to reduce code duplication by dropping the Start-AXAutoRun function and replacing it with a very similar function that takes a command parameter for the AX -startupcmd parameter but I haven’t done that yet.  I hadn’t previously had a function for importing label files.  I was just doing this with a few lines of code in my build process.  Just one of the perils of building this weekly in my spare time.  Optimization through iteration.

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