In my previous post I discussed how you could use your .dlls in an On Prem enviroment hosted on your local machine for those who hasn´t jumped to the cloud yet. https://businesscentralgeek.com/how-to-use-dotnets-for-bc-on-premise

In this post I will show you how to do it in a Docker container. The purpose is to test your extensions and .dlls in the lasts versions of Business Central before updating your production app. This is a good practice to make sure they work correctly in every minor and major update.

How to do it?

The process is similar but instead of pasting the .dll files on the root folder of our local machine we need them on the root of the container.

If you are working with Docker I assume you already have installed ‘BcContainerHelper’. We will use a function for copying the files. Learn more about it here: https://freddysblog.com/2020/08/11/bccontainerhelper/

Now, we will use ‘Copy-FileToBcContainer’ in PowerShell for every .dll file and dependencies if needed.

Copy-FileToBcContainer -localPath -containerName -containerPath

Local Path

The local path its simply the path in which you have the .dll files in your local machine.

E.g. “C:\Program Files\Assemblies\DynamicTK.dll”

Container Path

When you try to publish the extension in VS Code an error will appear asking for the file in the root. In this case ‘C:\Program Files\Microsoft Dynamics NAV\190\Service\Add-Ins’. This is the path for the container in which we will place the files.

You can explore docker directory in its cmd and look for that folder:

Example:

‘Copy-FileToBcContainer -localPath “C:\Program Files\Assemblies\DynamicTK.dll” -containerName bcsandbox01 -containerPath “C:\Program Files\Microsoft Dynamics NAV\190\Service\Add-Ins\DynamicTK.dll”‘.

Note that the name of the file is required in both local path and container path, otherwise an error will be displayed:

Restart Container

Finally, once you have run the script, you just need to reestart the container. Similar to restarting the instance in our machine. Now when you publish your extension VS Code won´t show any errors:

Hope you find it useful.

DLLs in Docker? (BC On Prem)

Post navigation


2 thoughts on “DLLs in Docker? (BC On Prem)

Leave a Reply

Your email address will not be published. Required fields are marked *