Repository Template for MSDyn365BC Projects

Repository Template for MSDyn365BC Projects

Sometimes it’s hard to start. Especially when everything is new. You have to deal with the new programming language Microsoft AL. You are facing the challenge to use a new Source Code Management like Git. And finally, your CI build automation in Azure DevOps expect a well structured project.

I know these problems. Therefor, I provide templates for Microsoft Dynamics 365 Business Central projects to my developers.

You find my example repository for Business Central (BC15) at GitHub:

https://github.com/megel/MSDyn365BC-15-Template

Company Specific Information

OK, how to use it? First of all I suggest to fork the repository. Afterwards, you should add / change your company specific information like:

  • Publisher
  • Default App Description
  • Company URL
  • Logo
  • Email
  • Prefix
  • EULA

Most of these information are defined in my app.json:

{
    "id":  "",
    "name":  "",
    "publisher":  "My Company",                             
    "version":  "1.0.0.0",
    "brief":  "My awesome application!",
    "description":  "",
    "privacyStatement":  "",
    "EULA":  "",
    "help":  "https://my-company.com",
    "url":  "https://my-company.com",
    "logo":  "assets/logo.png"
}

Finally, check & improve the defaults in my “.tools/Invoke-InitProject.ps1”:

Build Automation

I use Azure DevOps with build automation in my projects. Therefor, my template contains also a “.devops” folder and a “azure-pipelines.yml”.

Customize or replace this content with your CI-pipeline templates. I use ALOps and examples are provided at GitHub as well:

https://github.com/HodorNV/ALOps/tree/master/Examples

Using the template

In my opinion, a project setup should be ready in less than 5 minutes. But first of all, you need the template files.

One possibility is to download the template as a zip file as follows:

Secondly, extract the content into your local project folder. After this, you get these files::

Another option – my preferred way – is to download and extract the template automatically by PowerShell. My used script is:

# Download the Project Template
$source   = "https://github.com/megel/MSDyn365BC-15-Template/archive/master.zip"
$template = "$($env:TEMP)/template"
Invoke-WebRequest "$source" -OutFile "$template.zip"
Expand-Archive "$template.zip" -DestinationPath "$template" -Force
(Get-Item "$template/*") | ? { Copy-Item -Path "$($_.FullName)/*" -Recurse -Destination . }

Note: You must change the “source” URL to your repository.

Init the Projects

Now it’s time to run the “Magic”! Open your PowerShell in your project folder (project folder must be the current folder) and execute “.tools/Invoke-InitProject.ps1” by:

# Initialize the Project
.tools/Invoke-InitProject.ps1

Afterwards, follow the instructions of the script. You can change the defaults or accept by pressing [ENTER]:

As result you get a configured app and test project. Additionally, my script generate a VSCode workspace file as well as a “readme.md” documentation based on “.tools/readme.template.md” and script parameters like app name and description.

Last but not least my script open the project folder in VS Code:

During the script execution, my “app.json” was modified. Now it contains the used parameters like: app name, publisher, description, id range, dependencies, …

Conclusion

First of all, it takes little to prepare your template for your needs. Then you can download your project template to set up a new MSDyn365BC project. In other words, your local repository contains all the projects and files needed to start the development.

Secondly, my PowerShell script helps to initialize your project. As result, your Apps – “app.json” files – as well as the dependencies between are configured. Than it is up to you to individualize more.

You are almost done when you commit and push your local changes to your remote repository in Azure DevOps. Now as last step, configure your CI / CD pipeline as usual and start the first build of the created project.

… Happy Sharing and don’t forget #NeverStopLearning

Share

One thought on “Repository Template for MSDyn365BC Projects

  1. Thank you very much for sharing πŸ™‚
    I will try and adjust your procedure in my PowerShell projects.

Comments are closed.

Comments are closed.