Prepare for build:
This task should perform a database & packages backup and import/update all the necessary windows registry. Add a PowerShell task and point to the PrepareForBuild.ps1 script:
Arguments: -DynamicsSDKPath(“C:\DynamicsSDK”) -VSO_ProjectCollection(“https://xxxx.visualstudio.com/DefaultCollection/”)
There arguments must be provided because they are dynamic and you should inform therefore the script can read and create them as windows registry:
Backups:
Be careful with this scrip because after the backup it’s done it will perform a restore with the same backups as an attempt of maintain the test scenarios, so do not stop the task in the middle or something like these.
It won’t perform a new backup if there already is one older backup in the backup folder. In this case I recommend to create a copy task before this one.
Build Solution:
This task should perform a full build of your working packages. Create a MSBuild task and point to the AXModulesBuild.proj file. Basically what this project are going to do is call and execute several files located on the DynamicsSDK folder.
Arguments:
- Platform: Use your predefined variable to set if it is a 64 bits or a 32 bits application.
- Configuration: Use your predefined variable to set the platform configuration.
- MSBuildArguments:
- /p:OutputPath=”$(Agent.BuildDirectory)\Packages”.
- /p:LogPath=”$(Agent.BuildDirectory)\Packages\log.xml”
- MSBuid: It depends of your visual studio version. In my case that was the 14.0 (VS2015).
- MSBuild Architecture: 64 ou 32 bits, it depends of your S.O.
The purpose of the output and log arguments is to define where is the built packages and where to put the log file.
Deploy Reports:
With this step you can deploy all SRSS reports at once. Add a PowerShell task and point it DeploySSRSReports.ps1 file.
Arguments: -DeployReports(“True”)
Database Sync:
This step will perform a full database synchronize. Add a MSBuild task and point to the SyncEngine.proj:
- MSBuid: It depends of your visual studio version. In my case that was the 14.0 (VS2015).
- MSBuild Architecture: 64 ou 32 bits, it depends of your S.O.
Generate Packages:
There is no point doing the previous steps without generate a new deployable package and that is what we’re going to do in this step. Add a PowerShell task and point it to the “GeneratePackage.ps1″:
Arguments:
- -BuildPackagePath “$(Agent.BuildDirectory)\Packages” – The path where to produce the deployable packages.
- -BuildMetadataPath “$(Agent.BuildDirectory)\Packages” – The path to the build metadata.
- -BuildBinPath “$(Agent.BuildDirectory)\Bin” The path to the build binaries.
Publish Deployable Package:
With this task we’re able to upload the previous created deployable package to VSTS. Add a Copy and Publish Build Artifacts task and setup it as follow:
- CopyRoot: $(Agent.BuildDirectory)
- Contents: Packages\*.zip
- Artifact Name: Packages
- Artifact Type: Server
Each of these parameters are telling were to find the deployable packages and where it should be uploaded:
Test start:
This step get done the necessary step for the unit test execution. Add a PowerShell task and point it to the “TestStart.ps1” file:
Basically what this is import the “DynamicsSDKCommon.psm1″ module file again and start the Microsoft Dynamics AX Batch Management Service:
Arguments: -BuildNumber “$(BUILD_BUILDNUMBER)” – The current build number.
Visual Studio Test:
If you aren’t used to the test framework from AX you should read this first. The test framework it’s a powerful tool which provide us to schedule test functionality’s and analyse results through code and in large scale.
Depending on the the order that you use in your build, you can use this step as a required step for the deployable package generation and know when exactly some particular scenario stop from working. Anyway, there are several scenarios where this tool can be well used.
Add a VS Test task and setup as follow:
- Test Assembly: $(Agent.BuildDirectory)\Packages\*\Bin\$(TestAssembly) – Speciefies where is the location from the test assembly files that is the .dll from test package.
- Test Filter:$(TestFilter) use this if you want to filter some particular test.
- Run Settings File: Point to your settings file. This should be use if you want to change any particulars option on the test run. In my case I changed the location of the test result file and .NET framework version:
You can get a template from this .xml file and more information about the tags here.
- Code coverage: false
- Upload Test Attachments:True
- Other console options: /UseVsixExtensions:true
Test end:
This step end the test execution and it requires the same parameters from the test start task. Add a PowerShell task and point it to the “TestEnd.ps1” file:
Schedule:
Go to Trigger tab page and flag the schedule checkbox and setup the time that best suit you.
Thanks for you time guys.