Building the Exam App Installer
Relevant source files
The following files were used as context for generating this wiki page:The PeP Exam App installer is a critical component for distributing the secure, locked-down exam environment to students. The build system uses a combination of a PowerShell script for orchestration and the Inno Setup 6 compiler for creating the final .exe installer. This system handles versioning, application publishing, and packaging into a single, distributable file.
The installer is not just for initial setup; it is also a key part of the auto-update mechanism. The Exam App client can check a server endpoint for new versions, download the latest installer, and execute it silently to apply updates. This ensures that students are always using the most recent and secure version of the application.
Sources: PeP.ExamApp/Installer/README.md, PeP.ExamApp/Installer/build-installer.ps1, PeP.ExamApp/Services/UpdateService.cs
Prerequisites
To build the installer, the following software must be installed on the development machine:
| Software | Purpose | Link |
|---|---|---|
| Inno Setup 6 | The compiler that creates the .exe installer from the .iss script. | jrsoftware.org |
| .NET 8 SDK | Required to build and publish the PeP.ExamApp itself. | - |
The build script will attempt to locate the Inno Setup compiler (ISCC.exe) in its default installation path.
Sources: PeP.ExamApp/Installer/README.md, PeP.ExamApp/Installer/build-installer.ps1:71-88
The Build Process
The entire build process is automated by the build-installer.ps1 PowerShell script. This script orchestrates several steps to produce the final installer and its checksum file.
Build Script (build-installer.ps1)
The script accepts several parameters to customize the build process.
| Parameter | Type | Description | Default |
|---|---|---|---|
-Version | [string] | The version number for the build (e.g., "1.2.3"). This is a mandatory parameter. | 1.0.0 |
-Configuration | [string] | The build configuration to use for publishing the app. | Release |
-SkipPublish | [switch] | If present, the script will skip the dotnet publish step and use existing files in the publish directory. | false |
-SkipInstaller | [switch] | If present, the script will only publish the application and will not create the installer. | false |
Sources: PeP.ExamApp/Installer/build-installer.ps1:5-10
The following diagram illustrates the workflow executed by the build-installer.ps1 script.
Build Output
After a successful build, the following files are placed in the PeP.ExamApp/Installer/Output/ directory:
PeP.ExamApp_Setup_X.X.X.exe: The final installer executable.PeP.ExamApp_Setup_X.X.X.sha256: A text file containing the SHA256 hash of the installer, used for verification during auto-updates.
Sources: PeP.ExamApp/Installer/README.md, PeP.ExamApp/Installer/build-installer.ps1:115-122
Installer Architecture (PeP.ExamApp.iss)
The core of the installer is the Inno Setup Script (.iss) file. This file defines everything about the installer, from the files it contains to the dialogs it shows and the registry keys it creates.
Key [Setup] Directives
The [Setup] section contains global settings for the installer.
| Directive | Description | Example Value |
|---|---|---|
AppName | The name of the application. | PeP Exam App |
AppVersion | The version of the application, defined by the build script. | {#MyAppVersion} |
DefaultDirName | The default installation directory. | {autopf}\PeP Exam App |
OutputBaseFilename | The base name for the output installer file. | PeP.ExamApp_Setup_{#MyAppVersion} |
SignTool | Command to sign the installer and uninstaller (commented out by default). | signtool sign ... |
PrivilegesRequired | Ensures the installer requests administrator privileges. | admin |
Sources: PeP.ExamApp/Installer/PeP.ExamApp.iss
Installer Features
The installer supports several features for both users and administrators, configured within the .iss file.
- Silent Installation: Can be run with
/SILENTor/VERYSILENTflags for automated deployments. - Custom Directory: Users can choose where to install the application.
- Desktop & Start Menu Shortcuts: Creates standard application shortcuts.
- Auto-Restart Applications: The
/RESTARTAPPLICATIONSflag, used by theUpdateService, allows the installer to close the running application before updating. - Clean Uninstall: Removes all application files and registry keys.
Sources: PeP.ExamApp/Installer/README.md, PeP.ExamApp/Services/UpdateService.cs:113-120
Auto-Update Workflow
The installer is a crucial part of the application's auto-update mechanism. The UpdateService in the Exam App client works in tandem with a server-side API endpoint to manage updates.
Update Sequence
The following diagram shows the sequence of events when the Exam App checks for an update.
Server-Side Configuration
The web server provides update information via the GET /api/examapp/update endpoint. The data for this response is sourced from the ExamAppUpdate section of the server's appsettings.json configuration file.
Sources: Controllers/ExamAppController.cs:29-45, PeP.ExamApp/Installer/README.md
The JSON response structure is defined as follows:
| Field | Type | Description |
|---|---|---|
version | string | The new version number. |
downloadUrl | string | The public URL to download the new installer .exe. |
releaseNotes | string | Notes about the new version, displayed to the user. |
releaseDate | string (ISO 8601) | The date the update was released. |
isMandatory | boolean | If true, the user is forced to update. |
minimumVersion | string | The minimum version required to use the app. |
checksum | string | The SHA256 hash of the installer file for verification. |
Sources: Controllers/ExamAppController.cs:47-56, PeP.ExamApp/Installer/README.md
Client-Side Implementation (UpdateService.cs)
The UpdateService class encapsulates the client-side logic for handling updates.
CheckForUpdateAsync(): Makes the API call to the server and deserializes theUpdateInforesponse. It compares the new version with the current version.DownloadUpdateAsync(): Downloads the installer from thedownloadUrl. After downloading, it verifies the file's integrity by comparing its SHA256 hash with thechecksumfrom the update info.InstallUpdate(): Launches the downloaded installer process with the/SILENT /RESTARTAPPLICATIONSarguments and then shuts down the current application.
Sources: PeP.ExamApp/Services/UpdateService.cs:48-127
Full Deployment Workflow
Deploying a new version of the Exam App involves coordinating the build of the installer, hosting it, and updating the server configuration.
The following diagram outlines the end-to-end deployment process.