Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Architecture Overview

Portable VS Code & VSCodium Manager uses a strict 4-layer PowerShell 7.x architecture designed for zero external module dependencies, high performance via direct .NET APIs, and complete portability without Administrator elevation.


Directory & Layer Map

{ROOT}\
├── main.bat                        Interactive launcher (invokes pwsh.exe)
├── config.ini                      Manager settings & INI profile pointers
├── editor.ini                      Personal editor [Settings] & [Extensions]
├── README.txt                      Standalone runtime doc (packaged in release ZIPs)
├── profiles\                       Opt-in active INI profiles (discovered dynamically)
│   ├── *.ini                       Settings profiles (low-end, no-ai, privacy, etc.)
│   └── ext-*.ini                   Extension packs (ext-general, ext-python, etc.)
├── logs\                           Auto-created daily verbose logs (30-day retention)
└── src\
    ├── install.ps1                 [Layer 4] CLI entrypoint: fresh install
    ├── update.ps1                  [Layer 4] CLI entrypoint: in-place binary update
    ├── configure.ps1               [Layer 4] CLI entrypoint: standalone configurator
    ├── uninstall.ps1               [Layer 4] CLI entrypoint: removal & cleanup
    ├── core\                       [Layer 3] Domain logic & orchestration
    │   ├── config.ps1              INI parser, profile/editor loader & defaults
    │   ├── edition.ps1             Product/channel metadata, version & ripgrep lookup
    │   ├── discovery.ps1           Multi-source portable install auto-discovery
    │   ├── settings.ps1            settings.json schema, JSONC parser & deep merger
    │   └── dependencies.ps1        Extension dependency detection & portable installers
    ├── utility\                    [Layer 2] Low-level OS & I/O primitives
    │   ├── filesystem.ps1          HttpClient download, ZipFile extract, fast delete
    │   ├── path.ps1                User PATH manager + WM_SETTINGCHANGE broadcast
    │   └── registry.ps1            .NET Microsoft.Win32.Registry manager
    └── event\                      [Layer 1] Cross-cutting telemetry & UI
        ├── logger.ps1              Verbose daily file logger & retention pruner
        └── progress.ps1            Throttled inline wget-style progress bar

Dependency Flow

flowchart TD
    BAT["main.bat"] --> EP["Entrypoints: install / update / configure / uninstall"]
    EP --> CORE["src/core: config, edition, discovery, settings, dependencies"]
    CORE --> UTIL["src/utility: filesystem, path, registry"]
    CORE --> EVT["src/event: logger, progress"]
    UTIL --> EVT
    EVT --> PROG["progress.ps1"]
  • Strict Acyclic Layering: Entrypoints dot-source all layers cleanly; library modules guard dot-sourcing via Get-Command checks so re-sourcing is idempotent and never resets $script: state.
  • Root Resolution Depth: Because src\core\config.ps1 and src\event\logger.ps1 reside two levels below {ROOT}, fallback $ScriptRoot computation always traverses two parent directories (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent).

Key Architectural Decisions

1. Pure .NET [Microsoft.Win32.Registry] Instead of PowerShell Registry Cmdlets

PowerShell’s HKCU:\ Registry provider interprets * as a wildcard in -Path (and New-Item lacks -LiteralPath), causing New-Item -Path "HKCU:\Software\Classes\*\shell\VSCode" to expand across thousands of file-extension subkeys or stall. Using [Microsoft.Win32.Registry]::CurrentUser (CreateSubKey, OpenSubKey, SetValue, DeleteSubKeyTree, DeleteValue) directly completely eliminates wildcard hazards and scans targeted shell keys in milliseconds.

2. Strictly Opt-In INI Profiles (profiles\*.ini) + Personal editor.ini

Rather than hardcoding preset dictionaries in PowerShell or shipping huge commented-out blocks in config.ini, every optional profile is a standalone, active .ini file in profiles\. Get-ManagerConfig loads only the profile INIs listed in OptionalProfiles and the file referenced by EditorConfigFile. Dropping a new .ini file into profiles\ immediately makes it discoverable without code edits.

3. Install Step Ordering (Dependencies → Settings → Extensions)

src\install.ps1 resolves configured profiles, installs required portable toolchains (ripgrep, git, python, etc.) before writing settings.json, and merges all resolved settings + auto-wired executable paths in a single clean write. This guarantees {ripgrep_path} and extension path keys (todo-tree.ripgrep.ripgrep, git.path, etc.) point to real portable binaries on the very first write with zero spurious warnings or redundant .bak files.

4. Exact Directory-Boundary Safety

All path-scoped operations prevent prefix collisions (such as D:\IDE\VSCode accidentally matching D:\IDE\VSCode-Insiders):

  • Remove-UserPathEntry compares exact $TargetDir or $TargetDir\*.
  • Stop-EditorProcessesInDir checks $_.Path.StartsWith("$Dir\", OrdinalIgnoreCase).
  • Test-RegistryValueMatchesDir matches directory boundaries via regex (?:^|["'\s])<Dir>(?:\\|["'\s]|$).
  • Expand-ZipWithProgress enforces Zip Slip guards with trailing directory separator checks.

5. Official Per-Program Registry Keys & Non-Admin Portability

Portable tools installed by dependencies.ps1 never require Admin elevation and always register under their official HKCU vendor/program keys (e.g., HKCU\Software\GitForWindows, HKCU\Software\Python\PythonCore\<X.Y> per PEP 514, HKCU\Software\Node.js, HKCU\Software\Kitware\CMake, HKCU\Software\ripgrep) plus HKCU\Software\Microsoft\Windows\CurrentVersion\App Paths\<exe>.