HowTo - Set up a development environment for BusinessCentralApps

Introduction

Every time I try to create a customization for “BusinessCentralApps”, I have problems setting up an executable environment. I think this is because I only work with it from time to time and remove my environments when I have done what I wanted to do. So that I don't have to search so long in the future, I want to share my findings on setting up a development environment for BusinessCentralApps here.

Prerequisites

First you need to check if you have all the prerequisites

Access to the Github Repo

If you don't already have access to the BusinessCentralApps Repo on Github you can request Access by filling the following form REQUEST ACCESS.


Hardware

Check if your hardware is good enought. You should have at least
  • Hard disk space: 500 MB.
  • CPU: Four cores minimum
  • Memory:
    • 16 GB for development only.
    • 32 GB for developing and deploying locally.
    • 64 GB for developing large apps.

For more info see AL Development Requirements

Sofware

There is a bunch of software you should have installed to get everything running. You can donwload everything and install it the classic way or you can use the provided winger or chocolatey commands. If you want to use chocolatey you need to install it first. Check out the chocolatey website for more information.

PowerShell 7

Lets start with somthing optional, PowerShell 7. You don't need it, but it makes things easier because it remembers your commands even after you closed it or restarted your pc.

Git 

You need git. Pretty sure you already have it. If not get it.

Visual Studio Code with AL Language Extension

First you need to install vs code.
After you installed vs code go to Extensions and search for "AL Language extension for Microsoft Dynamics 365 Business Central" and install the extension.
Then go to the extension page (inside vs code) and "Switch to Pre-Release version" for the AL Language extension.
 

GitHub CLI

You need to be logged in to your Github Account to clone the repo. For this you need to have GitHub CLI installed.

Docker

You can choose between Docker Desktop and Docker Engine. I prefere Docker Desktop but it is only free under certain conditions. There is a great post from freddy about the diffrences on his blog: https://freddysblog.com/2021/10/30/docker-and-business-central/

I never installed Docker Engine but there is a script out there to do it for you: https://github.com/microsoft/nav-arm-templates/blob/master/InstallOrUpdateDockerEngine.ps1


For Docker Desktop you need to enable the "Hyper-V" Windows feature. Then you can install Docker Desktop.
After the installation set "Use WSL 2 instead of Hyper-V" to false and switch to Windows Containers.


Setting it up

Now we are ready to set everything up. First we need to clone the Repo.
 
Note: If you are working with Windows 11, the “Developer drives” feature should be used and the project should be cloned to the developer drive.

If you are working with Windows 10, “Virus and threat protection” should be added as an exception in Windows for the directory in which the project is stored. 
 
Run the following commands in PowerShell 7
 
Login to Github via GitHub CLI
gh auth login
 
Switch directory into D:/AL and then clone the repo into this directory. If you have a fork you can clone the fork instead.
cd D:/AL/
git clone https://github.com/microsoft/BusinessCentralApps.git
 
Switch to the project directory
cd D:/AL/BusinessCentralApps
 
Create a local Docker and initial build of all apps in the project
The prompts can all be confirmed with Enter.
But you should enter something for the password, e.g. admin
The script downloads the required artifacts / .NET dlls etc. in this step.
The DLLs are needed later to be able to compile the project
The whole process can take several hours
.\App\.AL-Go\localDevEnv.ps1
 
Now you should have a Docker Container with all the Apps up and running. 
 
For the last steps we need to open the Project in VS Code. I like to work with the workspace "SystemBaseAndTests" but you dont have to use this workspace.
But in my case i'am adding a launch configuration to the SystemBaseAndTests workspace file so all apps from this workspace can use the same launch configuration.
 
{
    "name": "Your own server",
    "request": "launch",
    "type": "al",
    "environmentType": "OnPrem",
    "server": "http://bcserver",
    "serverInstance": "BC",
    "authentication": "UserPassword",
    "breakOnError": "All",
    "launchBrowser": true,
    "startupObjectId": 130451,
    "startupObjectType": "Page",
    "enableLongRunningSqlStatements": true,
    "enableSqlInformationDebugger": true,
    "tenant": "default",
    "usePublicURLFromServer": false,
    "schemaUpdateMode": "ForceSync",
    "dependencyPublishingOption": "Ignore"
}


The be able to compile the apps we need to set the .netpackages in the settings. In my case i'am adding the settings also to the SystemBaseAndTests workspace file.

"al.assemblyProbingPaths": [
  "./.netpackages",
  "C:/ProgramData/BcContainerHelper/compiler/bcserver/dlls/OpenXML",
  "C:/Program Files/dotnet/shared/Microsoft.NETCore.App/8.0.2",
  "C:/Program Files/dotnet/shared/Microsoft.AspNetCore.App/8.0.2",
  "C:/ProgramData/BcContainerHelper/compiler/bcserver/dlls/Service",
  "C:/ProgramData/BcContainerHelper/compiler/bcserver/dlls/Mock Assemblies"
]

Note: The path to the BC Service should not be stored in the assembly probing paths. As other versions of the DLLs are sometimes used here and errors then occur during compilation. In short, only specify what is in the script above and no more.

Currently i'am also deactivating all CodeAnalyzers except the CodeCop, but you can try to enable more.
"al.codeAnalyzers": [
  "${CodeCop}"
]
 
Thats it! 
Now you can start developing your contributions for BusinessCentralApps (or whatever you like to use it for)
 
 
If you have any feedback, like bugs, questions or ideas on how to improve this post. Let me know it 😊

Kommentare

Beliebte Posts aus diesem Blog

How to - Find or Check NAVServerConfiguration using Out-GridView