Working with Dynamics NAV add-ins can be time consuming. The issue with debugging Dynamics NAV add-ins is that every time you make a change to a dll you have stop the service, copy over the files, and start the service back up again. Since our dev team works with add-ins on a daily basis, we came up with a way to easily copy them from the Visual Studio solution to the proper Dynamics NAV folders. Jason Down came up with most of the script, I have simply expanded on it and made it a bit more generic.
This script is a very simple windows batch file. It allows you to set what service you want to restart, where your dlls are, and if you only want to copy over certain files from within that folder with a filter.
:: First arg is service name
if "%1"=="" (set servicename="Microsoft Dynamics NAV Server [DynamicsNAV71]") else (set servicename="Microsoft Dynamics NAV Server [%1]")
:: stop service
net stop %servicename%
:: Second arg is source folder
if "%2"=="" (set sourcedir=C:\repos\foundation\Dot-Net-Library\Addins\src\app\Addins\bin\release\) else (set sourcedir="%2")
:: Third arg as a filter
if "%3"=="" (set files=*.*) else (set files="%3")
:: set the destination folders
set rtc=C:\Program Files (x86)\Microsoft Dynamics NAV\71\RoleTailored Client\Add-ins\Ryan.Blog\
set service=C:\Program Files\Microsoft Dynamics NAV\71\Service\Add-ins\Ryan.Blog\
:: Copy the files
xcopy %sourcedir%%files% "%rtc%"
xcopy %sourcedir%%files% "%service%"
:: Start service back up
net start %servicename%
You can change the defaults to something that better suits your system. The first argument is the service name. The second is what folder to copy from. You may want to default this to a project you are currently working on. The last arg is a filter for what folder if you don’t want to copy over all the files. By default all files will be copied over.
Simple usage using the batch file:
Making things even easier
If you have a main project you are always coping from, but want to keep the script generic for other projects. You can make a shortcut. On your desktop, or wherever you want it, make a new shortcut that points to the script. After you enter in the location, insert your arguments. This way, to copy over your new add-ins, all you have to do is double click on your shortcut.
Hopefully this saves you some time when developing and debugging Dynamics NAV add-ins.