Earlier we were able to connect our DevOps build pipeline with the Build ERP Box that was part of our cloud ERP instances. But Microsoft discarded the Build server and gave us two options:
- Setup an Azure hosted pipeline that will compile the code without doing DB synchronization and prepare a deployable package of FinOps. This approach helps you avoid the setup, maintenance, and cost of deploying build virtual machines (VMs).
- Provision a separate ERP box under Cloud-hosted environments then connect the build pipeline with this box. This pipeline can do code compilation of code along with DB synchronization and can prepare a deployable package. Definitely this is going to incur monthly cost.
In this blog, we are going to share how to setup an Azure hosted build pipeline.
First step is to prepare projects of all custom models, then need to prepare and push all required artifacts to DevOps. Ensure that the required extensions are installed on DevOps.
Let’s have a look to all the steps in detail.
We need to add an empty project of every custom model in a solution. Projects type must be Finance Operations.
Sequencing of all the projects must be correct as per dependency of models.
Group all projects and solution in a separate folder in DevOps branch along with nuget.config and packages.config files. Will describe these 2 files later.
Artifacts (NuGet Packages)
Nuget packages are used to build X++ code. Compiled referenced packages such as Application Suite etc. are also part of this build.
Some of the Nuget packages are:
Microsoft.Dynamics.AX.Platform.CompilerPackage has X++ compiler and related tools that are required to do a build.
Microsoft.Dynamics.AX.Platform.DevALM.BuildXpp has the compiled X++ code for the Application Platform and related modules. This code is optimized for building.
Microsoft.Dynamics.AX.Application.DevALM.BuildXpp has the compiled X++ code for the Application and related modules. This code is optimized for building.
Above three packages are required till the platform update 10.0.17. In later versions, Application Suite is split into two packages. So, we need 1 more package i.e.
Microsoft.Dynamics.AX.ApplicationSuite.DevALM.BuildXpp has the compiled X++ code for the Application Suite module. This code is optimized for building.
Download nugget packages according to your service update version of FinOps from LCS shared library on your machine.
In Azure DevOps, create feed.
Click on Connect to FeedSelect Nuget.exe and copy content for nuget.config file.
As mentioned, add a nuget.config file to your project, in the same folder as yours .csproj or .sln file on DevOps branch
On dev machine, you should have downloaded nuget.exe v4.8.2 or a relevant version. Put nuget.exe and all the downloaded packages in one folder on your machine.
Download PowerShell script from here and put in same folder.
Put nuget.config in same folder as well just for reference.
Run power shell as administrative and run this script file. if the script keeps asking for your credentials and fails try adding -AddNetfx as a parameter. Reference.
Upload all downloaded packages from LCS to Azure artifacts one by one using power shell commands as nuget.exe push -Source “YOURFEEDNAME” -ApiKey az <packagePath>
You’ll get prompted for the user. Remember it needs to have enough rights on the project.
Now, prepare a packages.config file and upload on DevOps branch CICD folder. Reference.
<?xml version="1.0" encoding="utf-8"?> <packages> <package id="Microsoft.Dynamics.AX.Platform.DevALM.BuildXpp" version="7.0.6060.65" targetFramework="net40" /> <package id="Microsoft.Dynamics.AX.Application.DevALM.BuildXpp" version="10.0.886.67" targetFramework="net40" /> <package id="Microsoft.Dynamics.AX.ApplicationSuite.DevALM.BuildXpp" version="10.0.886.67" targetFramework="net40" /> <package id="Microsoft.Dynamics.AX.Platform.CompilerPackage" version="7.0.6060.65" targetFramework="net40" /> </packages>
Make sure that D365 extension is installed on DevOps
Build Pipeline Setup
Create a new build pipeline or import any existing one.
Give Pipeline a name and select agent with specification
Map TFS branch
Keep default values of Compile X++.
Set path for Nuget Install Packages
Keep values of Update Model Version
Keep values of Copy Binary Dependences to: …
Set solution path and copy MSBuild Arguments. Reference.
Keep default values of Copy X++ Compile Log Files to: …
Keep default values of Use Nuget 3.3.0. Version may need to change depending on need.
Keep default values of Create Deployable package.
Keep default values of Add License to Deploy Package
Keep default values of Publish Artifact: drop
Save all the changes and run the pipeline and resolve the issues if there are any. Whenever there are new changes checked in TFS in the same branch, we can run this pipeline to build all models to get a deployable package.