Deploy Dynamics GP during development using Visual Studio External Tools Menu
I’ve never written this up before, but is a useful technique I use to allow the deployment of GP from the current project active build directory to the application addins folder.
Note that in this example PowerShell script, it will empty the addins folder before deploy. This may not be appropriate where other addins are present, tweak the deploy.ps1 script as appropriate for your development environment.
Setup external tool
Create a Deploy directory in the root of the project you wish to enable for copy deployment to the GP addins folder.
Save the following Deploy.ps1 script to that folder
Param(
[string]$deployFrom,
[string]$deployTo
)
Write-Host "Deploy from: $deployFrom To: $deployTo"
Remove-Item -Recurse -Force "$deployTo\*"
Get-ChildItem -Path $deployFrom -Recurse | Copy-Item -Destination $deployTo
Write-Host "Deploy complete"
Set up the external tool for launching the powershell script:
Command:
C:\windows\system32\windowspowershell\v1.0\powershell.exe
Arguments:
-File "$(ProjectDir)\Deploy\Deploy.ps1" "$(TargetDir)" "C:\Program Files (x86)\Microsoft Dynamics\GP2018\AddIns"
Title:
Deploy GP Add in
Use Output window checkbox checked
This will add a menu under the Visual Studio Tools menu of “Deploy GP Add in”, that will run the powershell script added to the project. The script takes the current project folder and uses it as a source to deploy GP from the current build target directory. Thus the deployment will honour the configuration type currently selected and the project currently selected will be selected as source.
To assign a keyboard shortcut
From Visual Studio Menu select Tools>Customize
Click “Keyboard” button
Use the show commands containing: search box to search for tools.external:
Then assign a shortcut by clicking the shortcut key combations while focus is on the “Press shortcut keys:” field