Tags

, , , , , , , , ,

The Get-AXTFSCombinedXpo custom PowerShell function is used for getting code out of TFS as an .xpo.  At my current job, we sometimes have to hotfix .xpos for builds.  I know that the trend is to move away from pushing .xpos but when it comes to hotfixes for builds, .xpos are significantly faster than creating another build and pushing a model.

We have a team dedicated to unit and regression testing and we regression test every model build before it is moved to production.  When we discover issues in the model build, we hotfix the build using .xpos so we can continue regression testing.

This PowerShell function uses both tf.exe and the TFS Power Tools to export the .xpo.  To use this function, you will need to run it on a server that has Visual Studio installed and connected/synched with TFS and have the TFS Power Tools installed.  Because of these requirements I run this from either my development server or from my development build server.

You will need to add some code to your profile as we’ve done for other functions.

ProfileAdd

The tf.exe reference should already exist in your profile for the TFS sync used by the build function.  The Microsoft.TeamFoundation.PowerShell reference is for the TFS Power Tools.

The Get-AXTFSCombinedXpo custom PowerShell function takes between 1-7 parameters:

  • Version (The TFS version to retrieve)
  • DateFrom (Used to set a start datetime to look up a range)
  • DateTo (Used to set an end datetime to look up a range)
  • OutputFile (The exported .xpo file)
  • TFSCollectionUrl (The URL used to connect to TFS)
  • TFSLocation (The location in TFS to get the files from)
  • 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
  • Get the TFS connection object
  • Create a temporary folder to hold the uncombined .xpos
  • Determine how to get the .xpos out of TFS based on the datetime parameters and the version
  • Loop through the files and save them as .xpos in the temporary folder location
  • Create the output file directory
  • Use CombineXPOs.exe to create the combined .xpo
  • Clean up the temporary folder and files

This function can be used to grab a single changeset, a range of changesets, a label version, or even the entire codebase.  I primarily use it to get a single changeset or a range of changesets.  Synching the TFS working folder is significantly faster than trying to grab a label version or the entire codebase with this function so I wouldn’t recommend using it for those purposes but it is able to if you want it to.

To get a range of changesets, use the date field information (datetime) of the TFS history to set the DateFrom and DateTo parameters.  Then use the latest changeset value in that range to set the Version parameter.  You can pass the DateFrom and DateTo as strings and the parameters will convert them to datetimes.  I have only tested the formatting of this using the en-us datetime format (M/d/yyyy h:mm:ss tt) so it is possible that you may run into issues if you are using another datetime format.  Please let me know if you experience any problems.

I am using this function with Visual Studio 2012, TFS 2012 and AX 2012 R2 CU7.  It has not been tested with other versions but may work with them anyway.

I am releasing this function as part of the D2DDynamics module (1.0.4) and as a standalone function at the current time.  I am determining whether or not I will remove the standalone functions that also exist in the module from Codeplex in the near future and will notify you through my blog if I do.