# squirrel/squirrel.windows architecture

> Architecture diagram of the GitHub repository squirrel/squirrel.windows, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/squirrel/squirrel.windows
- Repository: https://github.com/squirrel/squirrel.windows

## Overview

1. **What this repo is**
   Squirrel.Windows is an installer/update platform for Windows desktop apps. The architecture is centered on a release feed plus an app-local updater, rather than a traditional MSI-style installer.

2. **Top-level split: managed library vs native bootstrapper**
   The codebase is divided into a managed C# core (`src/Squirrel`) and several native C++ utilities/bootstrap components (`src/Setup`, `src/StubExecutable`, `src/WriteZipToSetup`). That split matters because initial install, update orchestration, and package manipulation are handled by different runtimes.

3. **Managed update engine (`src/Squirrel`)**
   This is the main reusable API surface. `UpdateManager` and related classes (`ReleasePackage`, `ReleaseEntry`, `DeltaPackage`, `UpdateInfo`, `FileDownloader`) implement the end-to-end update workflow: check feed, download packages, decide whether to use delta/full packages, and apply releases. The API is exposed through `IUpdateManager`.

4. **Release/package model**
   Squirrel uses NuGet packages as the artifact format for app releases. The important data boundary is the `RELEASES` manifest and the `.nupkg` files it references. The code contains support for package metadata, shell file handling, markdown parsing, and delta patching/compression (`BinaryPatchUtility`, `MsDeltaCompression`), which are all part of turning package versions into installable app states.

5. **Per-app maintenance executable (`Update.exe`)**
   `src/Update` builds the command-line updater/maintenance tool that lives alongside an installed app. It is responsible for app lifecycle operations such as install, update, shortcut/taskbar behavior, signing-related helpers, and handling Squirrel-specific startup events. The use of `Mono.Options` and multiple command-line entry points shows this is a local orchestration binary, not a UI app.

6. **Native bootstrap installer (`Setup.exe`)**
   `src/Setup` contains the bootstrapper that starts a first-time install or launch path. It includes platform-specific helpers like `MachineInstaller`, `FxHelper`, and `UpdateRunner`, plus WTL UI resources. This component is the boundary between “downloaded package contents” and “installed application directory/shortcuts.”

7. **Embedded payload and installer assembly**
   `src/WriteZipToSetup` and the `update.zip`/`flags1.bin` artifacts indicate that the bootstrapper is assembled with an embedded zip payload. This is a packaging boundary: the native setup binary is combined with update content so it can bootstrap installation without requiring a separate installer framework.

8. **Version detection and app-awareness**
   The library includes `SquirrelAwareApp` and `SquirrelAwareExecutableDetector`, which separate apps that know how to respond to Squirrel lifecycle events from those that don’t. This boundary matters because the updater may need to launch the app with special arguments or suppress normal startup during install/update transitions.

9. **Release-feed tooling and synchronization**
   `src/SyncReleases` is a command-line utility for managing/syncing release feeds, likely for publishing or mirroring `RELEASES` files and package sets. It is part of the distribution pipeline rather than the runtime update engine.

10. **Distribution is intentionally storage-agnostic**
   The documentation shows Squirrel can consume packages over simple HTTP and integrates with hosting models such as GitHub, Amazon S3, IIS, TeamCity, and Octopack. Architecturally, the app does not depend on a specific server product; it only requires a reachable release feed and package files.

11. **Install/update flow boundary**
   At runtime, the app checks for updates through `UpdateManager`, downloads release artifacts, applies them locally, and then hands control back to the installed app. The installer/update process is therefore mostly local disk I/O plus HTTP download, with the external feed serving as the only remote dependency.

12. **Test and validation layer**
   `test/Squirrel.Tests` uses many package and feed fixtures, plus helpers like `StaticHttpServer`, to simulate real update scenarios. The tests validate package parsing, update decisions, feed handling, and installer behavior against representative `.nupkg` and `RELEASES` inputs.

Main entry points: [`src/Squirrel/UpdateManager.cs`](https://github.com/squirrel/squirrel.windows/blob/develop/src/Squirrel/UpdateManager.cs) (UpdateManager), [`src/Squirrel/ReleasePackage.cs`](https://github.com/squirrel/squirrel.windows/blob/develop/src/Squirrel/ReleasePackage.cs) (Release model), [`src/Setup`](https://github.com/squirrel/squirrel.windows/tree/develop/src/Setup) (Setup.exe), [`test/Squirrel.Tests`](https://github.com/squirrel/squirrel.windows/blob/develop/test/Squirrel.Tests) (Squirrel tests)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_src["src"]
  node_squirrel_core["Update engine<br/>managed library"]
  node_update_manager["UpdateManager<br/>orchestrator<br/>[UpdateManager.cs]"]
  node_update_manager_check["Check updates<br/>feed query"]
  node_update_manager_download["Download releases<br/>download stage"]
  node_update_manager_apply["Apply releases<br/>install stage"]
  node_release_model["Release model<br/>package model<br/>[ReleasePackage.cs]"]
  node_release_entry["Release entry<br/>manifest record<br/>[ReleaseEntry.cs]"]
  node_delta_pkg["Delta patching<br/>package diff<br/>[DeltaPackage.cs]"]
  node_download_io["Downloader<br/>network io<br/>[FileDownloader.cs]"]
  node_pkg_utils["Package tools<br/>content tooling"]
  node_aware_detection["Aware apps<br/>app detection"]
  node_update_exe["Update.exe<br/>cli maintainer"]
  node_setup_exe["Setup.exe<br/>native bootstrapper"]
  node_setup_runner["Update runner<br/>bootstrap flow<br/>[UpdateRunner.cpp]"]
  node_setup_machine["Machine install<br/>privileged install"]
  node_setup_fx["Framework helper<br/>prereq helper<br/>[FxHelper.cpp]"]
  node_payload_packaging["Payload pack<br/>embedded payload"]
  node_sync_tool["SyncReleases<br/>release cli<br/>[Program.cs]"]
end

subgraph group_test["test"]
  node_tests["Squirrel tests<br/>test suite<br/>[Squirrel.Tests]"]
  node_test_server["HTTP server<br/>test harness"]
end

node_squirrel_core -->|"contains"| node_update_manager
node_update_manager -->|"checks"| node_update_manager_check
node_update_manager -->|"downloads"| node_update_manager_download
node_update_manager -->|"applies"| node_update_manager_apply
node_update_manager -->|"uses"| node_release_model
node_release_model -->|"parses"| node_release_entry
node_release_model -->|"selects"| node_delta_pkg
node_update_manager_download -->|"uses"| node_download_io
node_update_manager_apply -->|"uses"| node_pkg_utils
node_pkg_utils -->|"supports"| node_delta_pkg
node_aware_detection -->|"enables"| node_update_exe
node_setup_exe -->|"drives"| node_setup_runner
node_setup_exe -->|"includes"| node_setup_machine
node_setup_exe -->|"checks"| node_setup_fx
node_payload_packaging -->|"assembles"| node_setup_exe
node_sync_tool -->|"manages"| node_release_model
node_tests -->|"covers"| node_update_manager
node_tests -->|"covers"| node_release_model
node_tests -->|"uses"| node_test_server

click node_squirrel_core "https://github.com/squirrel/squirrel.windows/tree/develop/src/Squirrel"
click node_update_manager "https://github.com/squirrel/squirrel.windows/blob/develop/src/Squirrel/UpdateManager.cs"
click node_update_manager_check "https://github.com/squirrel/squirrel.windows/blob/develop/src/Squirrel/UpdateManager.CheckForUpdates.cs"
click node_update_manager_download "https://github.com/squirrel/squirrel.windows/blob/develop/src/Squirrel/UpdateManager.DownloadReleases.cs"
click node_update_manager_apply "https://github.com/squirrel/squirrel.windows/blob/develop/src/Squirrel/UpdateManager.ApplyReleases.cs"
click node_release_model "https://github.com/squirrel/squirrel.windows/blob/develop/src/Squirrel/ReleasePackage.cs"
click node_release_entry "https://github.com/squirrel/squirrel.windows/blob/develop/src/Squirrel/ReleaseEntry.cs"
click node_delta_pkg "https://github.com/squirrel/squirrel.windows/blob/develop/src/Squirrel/DeltaPackage.cs"
click node_download_io "https://github.com/squirrel/squirrel.windows/blob/develop/src/Squirrel/FileDownloader.cs"
click node_pkg_utils "https://github.com/squirrel/squirrel.windows/blob/develop/src/Squirrel/BinaryPatchUtility.cs"
click node_aware_detection "https://github.com/squirrel/squirrel.windows/blob/develop/src/Squirrel/SquirrelAwareApp.cs"
click node_update_exe "https://github.com/squirrel/squirrel.windows/tree/develop/src/Update"
click node_setup_exe "https://github.com/squirrel/squirrel.windows/tree/develop/src/Setup"
click node_setup_runner "https://github.com/squirrel/squirrel.windows/blob/develop/src/Setup/UpdateRunner.cpp"
click node_setup_machine "https://github.com/squirrel/squirrel.windows/blob/develop/src/Setup/MachineInstaller.cpp"
click node_setup_fx "https://github.com/squirrel/squirrel.windows/blob/develop/src/Setup/FxHelper.cpp"
click node_payload_packaging "https://github.com/squirrel/squirrel.windows/blob/develop/src/WriteZipToSetup/WriteZipToSetup.cpp"
click node_sync_tool "https://github.com/squirrel/squirrel.windows/blob/develop/src/SyncReleases/Program.cs"
click node_tests "https://github.com/squirrel/squirrel.windows/blob/develop/test/Squirrel.Tests"
click node_test_server "https://github.com/squirrel/squirrel.windows/blob/develop/test/Squirrel.Tests/TestHelpers/StaticHttpServer.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_squirrel_core,node_update_manager,node_update_manager_check,node_update_manager_download,node_update_manager_apply,node_release_model,node_release_entry,node_delta_pkg,node_download_io,node_pkg_utils,node_aware_detection,node_update_exe,node_setup_exe,node_setup_runner,node_setup_machine,node_setup_fx,node_payload_packaging,node_sync_tool toneBlue
class node_tests,node_test_server toneAmber
```

## Components

### src

Production code

- [Update engine](https://github.com/squirrel/squirrel.windows/tree/develop/src/Squirrel): managed library · Reusable C# API for checking feeds, downloading releases, and applying updates. · `src/Squirrel`
- [UpdateManager](https://github.com/squirrel/squirrel.windows/blob/develop/src/Squirrel/UpdateManager.cs): orchestrator · Coordinates update discovery, download, install, and application flows. · `src/Squirrel/UpdateManager.cs`
- [Check updates](https://github.com/squirrel/squirrel.windows/blob/develop/src/Squirrel/UpdateManager.CheckForUpdates.cs): feed query · Checks a release feed and computes available updates. · `src/Squirrel/UpdateManager.CheckForUpdates.cs`
- [Download releases](https://github.com/squirrel/squirrel.windows/blob/develop/src/Squirrel/UpdateManager.DownloadReleases.cs): download stage · Fetches release artifacts and manifests from the feed. · `src/Squirrel/UpdateManager.DownloadReleases.cs`
- [Apply releases](https://github.com/squirrel/squirrel.windows/blob/develop/src/Squirrel/UpdateManager.ApplyReleases.cs): install stage · Applies downloaded releases into the local app installation. · `src/Squirrel/UpdateManager.ApplyReleases.cs`
- [Release model](https://github.com/squirrel/squirrel.windows/blob/develop/src/Squirrel/ReleasePackage.cs): package model · Represents release entries, packages, and update metadata. · `src/Squirrel/ReleasePackage.cs`
- [Release entry](https://github.com/squirrel/squirrel.windows/blob/develop/src/Squirrel/ReleaseEntry.cs): manifest record · Parses RELEASES entries and package version references. · `src/Squirrel/ReleaseEntry.cs`
- [Delta patching](https://github.com/squirrel/squirrel.windows/blob/develop/src/Squirrel/DeltaPackage.cs): package diff · Handles delta packages and binary patch application. · `src/Squirrel/DeltaPackage.cs`
- [Downloader](https://github.com/squirrel/squirrel.windows/blob/develop/src/Squirrel/FileDownloader.cs): network io · Downloads packages and release assets over HTTP or similar transport. · `src/Squirrel/FileDownloader.cs`
- [Package tools](https://github.com/squirrel/squirrel.windows/blob/develop/src/Squirrel/BinaryPatchUtility.cs): content tooling · Helpers for package content type, shell files, markdown, and compression. · `src/Squirrel/BinaryPatchUtility.cs`
- [Aware apps](https://github.com/squirrel/squirrel.windows/blob/develop/src/Squirrel/SquirrelAwareApp.cs): app detection · Detects Squirrel-aware executables and lifecycle-aware startup behavior. · `src/Squirrel/SquirrelAwareApp.cs`
- [Update.exe](https://github.com/squirrel/squirrel.windows/tree/develop/src/Update): cli maintainer · Installed-app command line tool for local lifecycle and maintenance operations. · `src/Update`
- [Setup.exe](https://github.com/squirrel/squirrel.windows/tree/develop/src/Setup): native bootstrapper · First-run installer/bootstrapper that lays down the app and shortcuts. · `src/Setup`
- [Update runner](https://github.com/squirrel/squirrel.windows/blob/develop/src/Setup/UpdateRunner.cpp): bootstrap flow · Drives install/update execution from the native bootstrapper. · `src/Setup/UpdateRunner.cpp`
- [Machine install](https://github.com/squirrel/squirrel.windows/blob/develop/src/Setup/MachineInstaller.cpp): privileged install · Handles machine-wide install logic and Windows integration tasks. · `src/Setup/MachineInstaller.cpp`
- [Framework helper](https://github.com/squirrel/squirrel.windows/blob/develop/src/Setup/FxHelper.cpp): prereq helper · Checks and prepares runtime prerequisites for setup execution. · `src/Setup/FxHelper.cpp`
- [Payload pack](https://github.com/squirrel/squirrel.windows/blob/develop/src/WriteZipToSetup/WriteZipToSetup.cpp): embedded payload · Builds and embeds the zip payload used to assemble Setup.exe. · `src/WriteZipToSetup/WriteZipToSetup.cpp`
- [SyncReleases](https://github.com/squirrel/squirrel.windows/blob/develop/src/SyncReleases/Program.cs): release cli · Command-line utility for synchronizing or publishing release feeds. · `src/SyncReleases/Program.cs`

### test

Validation and fixtures

- [Squirrel tests](https://github.com/squirrel/squirrel.windows/blob/develop/test/Squirrel.Tests): test suite · Integration and unit tests covering update behavior and package parsing. · `test/Squirrel.Tests`
- [HTTP server](https://github.com/squirrel/squirrel.windows/blob/develop/test/Squirrel.Tests/TestHelpers/StaticHttpServer.cs): test harness · Static HTTP server used to simulate remote release feeds in tests. · `test/Squirrel.Tests/TestHelpers/StaticHttpServer.cs`

## Connections

- Update engine → UpdateManager: contains · The managed library centers on the update manager API.
- UpdateManager → Check updates: checks · UpdateManager delegates feed discovery to the check stage.
- UpdateManager → Download releases: downloads · UpdateManager coordinates release acquisition.
- UpdateManager → Apply releases: applies · UpdateManager drives local installation of new releases.
- UpdateManager → Release model: uses · UpdateManager consumes release metadata and package records.
- Release model → Release entry: parses · Release metadata is represented through release entries.
- Release model → Delta patching: selects · The release model distinguishes delta and full packages.
- Download releases → Downloader: uses · The download stage relies on a downloader component.
- Apply releases → Package tools: uses · Applying releases depends on package and patch helpers.
- Package tools → Delta patching: supports · Patch/compression helpers enable delta package handling.
- Aware apps → Update.exe: enables · Lifecycle-aware apps are launched through the maintenance tool.
- Setup.exe → Update runner: drives · The native bootstrapper uses the update runner for install flow.
- Setup.exe → Machine install: includes · Bootstrapper includes machine-wide installation behavior.
- Setup.exe → Framework helper: checks · Setup verifies prerequisites before continuing.
- Payload pack → Setup.exe: assembles · The payload is embedded into the setup binary.
- SyncReleases → Release model: manages · Sync tooling works on release feeds and package sets.
- Squirrel tests → UpdateManager: covers · Tests validate update decisions and application flow.
- Squirrel tests → Release model: covers · Tests validate package parsing and release metadata.
- Squirrel tests → HTTP server: uses · Tests simulate remote feeds with a local HTTP server.
