Skip to main content

How to Create Zonal OCR MSI Installer

Prerequisite:

  • MSBuild and signtool should be present on machine
  • ZonalOCR project should contain all required dlls and should build without any errors
  • You should be running the project in Visual Studio 2019 (not 2022 or later)

Steps:

  1. Open ZonalOCRInstaller project
  2. Navigate to appsettings.json and fill in next fields with correct values:
  3. When you first clone the project, you will need to run the efcKey.pfx file one time. When you have done this once, you will not need to do it again unless you reset your repository. This file located in your ZonalOCR\ZonalOCR directory and is run simply by double-clicking it. Go through, keeping all of the default settings, but when it asks for a password use the one that we store in LastPass. This is the same password that we will use for the ZonalOcrSignKeystorePassword.

MsBuildPath - path to MSBuild.exe. It is required for building ZonalOCR project
SignToolPath - path to signtool.exe. It is required for signing ZonalOCR executable and an installer itself.
ZonalOcrSignKeystoreFile - keystore with certificate. It is required for signtool.exe
ZonalOcrSignKeystorePassword - keystore password. It is required for signtool.exe. You can find it in LastPass. Please do not commit the password to git. 
ZonalOcrVersionNumber - is displayed in the Programs and Features control panel. Make sure this matches the version number in the ZonalOCR project

For some cases default values of other parameters can be also changed:
TargetDirectory - default installation directory
ProjectName - it is used for msi file name (it will be <ProjectName>.msi)
ProjectPublisher - is displayed in the Programs and Features control panel
ZonalOcrSolutionFolder - path to the ZonalOCR solution
ZonalOcrSolutionFile - ZonalOCR solution file
ZonalOcrCompiledFolder - path where installer will find compiled and obfuscated binares
ZonalOcrExecutable - ZonalOCR executable file

appsettings.json exampe:

{
  "TargetDirectory": "%ProgramFiles%\\eFileCabinet\\ZonalOCR",
  "ProjectName": "eFileCabinet Zonal OCR",
  "ProjectPublisher": "eFileCabinet",
  "MsBuildPath" : "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\MSBuild\\Current\\Bin\\MSBuild.exe",
  "SignToolPath": "C:\\Program Files (x86)\\Windows Kits\\10\\bin\\10.0.17763.0\\x64\\signtool.exe",
  "ZonalOcrSolutionFolder": "..\\..\\ZonalOCR",
  "ZonalOcrSolutionFile": "ZonalOCR.sln",
  "ZonalOcrCompiledFolder": "ZonalOCR\\bin\\ReleaseObfuscated",
  "ZonalOcrExecutable": "ZonalOCR.exe",
  "ZonalOcrSignKeystoreFile": "ZonalOCR\\efcKey.pfx",
  "ZonalOcrSignKeystorePassword": "salive.1",
  "ZonalOcrVersionNumber": "20.2.10.1"
}

  1. Build installer project. During the build <ProjectName>.msi will be created.

Troubleshooting:

Most problems encountered during the build will be related to MsBuildPath and SignToolPath. Verify that both executables exist at the specified paths. For example, if you have the Community edition of Visual Studio installed your MsBuildPath might need to be: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\MSBuild\\Current\\Bin\\MSBuild.exe"

Another common issue is if you try to run the project in Visual Studio 2022 or later it will fail without any clear explanation. This project has to be run in Visual Studio 2019. We're not sure why and hope to correct that before long.

A third trip-up is that the build will not work if you have never run the efcKey.pfx file (see step 3).