Dynamics 365 FinOps development using GIT

In this article I will be going over how we can setup a git repository for managing our customizations for D365 FinOps within Azure DevOps.

Create a new model

This step is only required for the purpose of this article. If you already have an existing model you can use that for further steps. 

See this article for details on how to create a new model.

For example, 

Copy the contents of the model folder created with your AOSSerive/PackagesLocalDirectory folder and store it somewhere. We will use this later to upload the contents of the model to git source control.

Remove the model from the environment so that it longer exists under AOSSerive/PackagesLocalDirectory. This is so that we can clone the source controlled version of the model on this location. 

Setting up a GIT repository

Navigate to your Azure DevOps project and click on the repos tab page.

Click on new repository

Provide an appropriate name for your repository and click Create

This will create a new repository for you where we will be checking in our code.

Clone the GIT repo

Download git bash within your development environment

Click on the Clone button from the Azure DevOps repo view and copy the clone URL

Open git bash in admin mode
Navigate to the the packages local directory path and enter the command git clone [clone URL] [Model name]


This will clone the contents of the repository into the folder named MyNewModel.

Add your model to the repo

Copy the contents of your model, that was mentioned earlier to this folder, for example,

Add a .gitignore file which lists all elements that is not required for checking.
Follow this sample to create one

Add the following to the beginning of the gitignore file for Dynamics365 elements
## Ignore Dynamics 365 files
/Metadata/**/bin
/Metadata/**/Reports
/Metadata/**/Resources
/Metadata/**/WebContent
/Metadata/**/XppMetadata
/Metadata/*/*.xml
/Metadata/*/*.xref
!/Metadata/**/LabelResources

Next enter the command git status within git bash. This will display all items that can be tracked by git source control. Notice that it has identified Descriptor and gitignore files only. This is because the model currently does not have any elements and the files that we do not require to be version controlled we have specified it in our gitignore file.

Enter the command git add .
This will add untracked changes to tracked changes stage them for commit



Enter the following command to commit the changes. This will commit the files to the local repository. But will not be pushed to the server yet.
git commit -m "Added MyNewModel"



Enter the following to push the changes to the server.
git push

Reload your repo within Azure DevOps and notice that the files are now uploaded to source control.

Check in your modification

Next we will make modifications to the current model. This is just to demonstrate how we can check in our changes whenever we make modifications to a model.

For example, add a new runnable class.

Navigate to git bash and enter the git status command. Notice that new untracked changes have been identified.

Enter the command git add . to add all elements for checkin. 
Enter the command git status to view the list of elements ready for checkin. Notice the runnable class has been automatically identified for check in.

You can check in all your files using the usual process.

The change should now also be visible within your source control.



You can use any other form of git source control management tool to achieve the same results as git bash.



Comments

Popular posts from this blog

D365FO - Create a multi-select lookup in batch jobs

Generate and download a csv file using X++

Creating a batch job with query based filter in D365 back-office