This is the sixth article in my series about setting up and working with your Dexterity Development Environments.
If you have not read the previous articles, please do so first using the links below:
- #Dexterity Development Environments – Part 1: Installation
- #Dexterity Development Environments – Part 2: Setting up Projects
- #Dexterity Development Environments – Part 3: Single Code Base
- #Dexterity Development Environments – Part 4: Creating Chunk Files
- #Dexterity Development Environments – Part 5: Creating Dictionary Assemblies
Disclaimer: This is the Musgravion principles of development machine setup. It is not the only method but it has worked for me for many years and has been fine tuned during my career. Feel free to use it if it works for you.
In the previous article we discussed creating and signing of Dictionary Assemblies. In this article we will cover automating more of the distribution process.
More Batch Files
To help automate the distribution process further, I created some more batch files to perform the additional tasks needed. They are listed below:
CHUNK.BAT
This batch file replaces the shortcut to Dexterity Utilities, allowing you to create the Dexterity chunk file from the command line. Note it uses a little hack to set the errorlevel value if the chunk creation fails.
@echo off cls echo Creating Chunk File(s) echo. if exist Project.cnk del Project.cnk C:\DexXX00\Dexutils.exe C:\DexXX00\Data\Dex.ini C:\DexXX00\Project\Project.mac rem Use find command to force errorlevel to be set if not exist Project.cnk echo 1|find "0" >nul
COPY.BAT
This batch file is optional and is used when you have a Visual Studio Tools Addin. It assumes that the Addin has been built and stored in the C:\DexXX00\Project\Addins folder. To automatically place the Addin DLL into this location, I set the Output Path for my Builds in Visual Studio to “..\..\Addins\”.
The purpose of this script is to code sign the DLL file and deploy it to the application folder. A side effect of this is that the last modified date of the DLL file is updated to match today’s build date.
@echo off cls echo Sign Addins - ProjectName echo. CD C:\DexXX00\Project\Addins echo Signing signtool sign /f 0123456789ABCDEF.pfx /p <Password> /t http://timestamp.comodoca.com/authenticode Company.ProjectName.dll if errorlevel 1 goto error signtool sign /fd sha256 /td sha256 /as /f 0123456789ABCDEF.pfx /p <Password> /tr http://timestamp.comodoca.com/authenticode Company.ProjectName.dll if errorlevel 1 goto error echo Copying to Application Addins Folder copy /y Company.ProjectName.dll "C:\DynXX00\Addins" CD C:\DexXX00\Project goto exit :error pause goto exit :exit
You will need to find and replace the DexXX00, DynXX00, GPXXXX and Project folders, as well as the Company, Project and ProjectName placeholders and the 0123456789ABCDEF.pfx certificate file. You will also need to replace the <Password> placeholder.
BUILD.BAT
This batch file is used to call the InstallAware software, which I use to create the Windows installers for my products. It also copies the resulting installer executables to a backup folder. The exact command to build your installer will be dependent on the software you use.
@echo off cls echo Build Installer for ProjectName echo. miabuild.exe "C:\DexXX00\Project\Installer\ProjectName.mpr" /r if errorlevel 1 goto error if not exist "C:\DexXX00\Project\Release\Single\ProjectName_*.exe" goto error copy "C:\DexXX00\Project\Release\Single\ProjectName_*.exe" "C:\Backups\DynXX00\" goto exit :error pause goto exit :exit
INSTALL.BAT
This final batch file is used to test the installer executables created by performing a silent install against each of the Microsoft Dynamics GP instances I have installed for that version. The command line parameters to enable a silent install for your installer will probably be different. This batch file also elevates permissions so that it can perform the installations.
@echo off cls echo Silent Install - Run as Administrator echo. :: BatchGotAdmin (Run as Admin code starts) REM --> Check for permissions >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" REM --> If error flag set, we do not have admin. if '%errorlevel%' NEQ '0' ( echo Requesting administrative privileges... goto UACPrompt ) else ( goto gotAdmin ) :UACPrompt echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs" "%temp%\getadmin.vbs" exit /B :gotAdmin if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" ) pushd "%CD%" CD /D "%~dp0" :: BatchGotAdmin (Run as Admin code ends) echo C:\DexXX00\Project\Release\Single\ProjectName_XX.00.00XX.exe /s INSTALL=TRUE TARGETDIR="C:\DynXX00\" echo. C:\DexXX00\Project\Release\Single\ProjectName_XX.00.00XX.exe /s INSTALL=TRUE TARGETDIR="C:\DynXX00\" echo C:\DexXX00\Project\Release\Single\ProjectName_XX.00.00XX.exe /s INSTALL=TRUE TARGETDIR="C:\DynYY00\" DYNINSTDESC="R2" echo. C:\DexXX00\Project\Release\Single\ProjectName_XX.00.00XX.exe /s INSTALL=TRUE TARGETDIR="C:\DynYY00\" DYNINSTDESC="R2" echo. if "%ERRORLEVEL%"=="0" goto exit pause :exit
Stay tuned for the final article on completing the distribution automation into a single click.
David
This article was originally posted on http://www.winthropdc.com/blog.
2 thoughts on “#Dexterity Development Environments – Part 6: Automating Distribution”