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

Portable VS Code & VSCodium Manager

A self-contained PowerShell 7.x manager for installing, preconfiguring, updating, backing up, and uninstalling Portable Mode copies of Microsoft VS Code and VSCodium (Stable & Insiders) on Windows—with non-admin HKCU Explorer context menus, User PATH integration, opt-in .ini profiles, and automatic portable toolchain dependencies.

Start here

NeedDocumentation
Install your first portable editorGetting started
Customize config.ini and editor.iniConfiguration
Enable optional profiles (privacy, no-ai, low-end, ext-*)Optional profiles & extension packs
Script or automate installs, updates, and backupsCLI reference
Understand portable toolchains (git, ripgrep, python, node, etc.)Extension dependencies & portable toolchains
Fix PowerShell 7, Todo Tree, or PATH issuesTroubleshooting
Understand the 4-layer PowerShell 7 architectureArchitecture
Look up internal module functionsModule & function API reference
Add new profiles, tools, or editor editionsExtending
Understand release .zip packaging rulesRelease packaging

Design boundaries

  • PowerShell 7.x required: All entrypoints enforce #Requires -Version 7.0; legacy Windows PowerShell 5.1 is not supported.
  • Zero Administrator elevation: Context menus, User PATH, and official per-program registry keys are written strictly under HKCU via .NET [Microsoft.Win32.Registry].
  • Opt-in INI profiles: Optional profiles under profiles\*.ini are loaded only when referenced in config.ini, -Preset, or interactive menus.
  • 100% portable toolchains: Missing extension dependencies are downloaded from official upstream Windows x64 portable builds and wired directly into PATH, HKCU, and settings.json.

Getting Started

This guide walks you through installing and managing a self-contained portable copy of Microsoft VS Code or VSCodium on Windows.


Prerequisites

  • Windows 10 / 11 (x64)
  • PowerShell 7.x (pwsh.exe) in PATH
    • This project intentionally requires PowerShell 7.0+ (#Requires -Version 7.0) because Windows PowerShell 5.1 is being phased out.
    • Install PowerShell 7 via winget:
      winget install Microsoft.PowerShell
      
    • Or download the portable Windows x64 ZIP from PowerShell/PowerShell Releases.
  • No Administrator privileges required: All context menus, PATH entries, and per-program tool registry entries are written under your user account (HKCU / User PATH).

First Installation via main.bat

  1. Extract the release archive (or clone the repository) to a folder of your choice.
  2. (Optional) Review config.ini to customize:
    • DefaultInstallDir (e.g., D:\IDE\{program_name})
    • DefaultToolsDir (e.g., D:\CLI\{tool_name})
    • DefaultProduct (vscode or vscodium) and DefaultChannel (stable or insiders)
    • OptionalProfiles (e.g., portable-essentials, privacy, no-ai, low-end, ext-general)
    • EditorConfigFile (e.g., editor.ini for your own custom settings/extensions)
  3. Double-click main.bat (or run main.bat "D:\IDE\VSCode" from a terminal to override the target folder).
  4. Choose Option 1 — Download & Install Portable Editor.

What Option 1 Does Automatically

  1. Downloads the latest official Windows x64 .zip archive (Microsoft CDN for VS Code, GitHub Releases for VSCodium).
  2. Extracts the archive into your target directory and creates the Portable Mode folders:
    • <InstallDir>\data\
    • <InstallDir>\data\user-data\User\
    • <InstallDir>\data\extensions\
  3. Registers 4 Windows Explorer right-click context menus (Files, Folders, Folder Background, Drives) under HKCU\Software\Classes.
  4. Adds <InstallDir>\bin to your User PATH so code / code-insiders / codium / codium-insiders work from any terminal.
  5. Checks software dependencies for any preconfigured extensions and installs missing portable tools (with User PATH & official HKCU registry keys).
  6. Writes your merged settings.json into <InstallDir>\data\user-data\User\settings.json.
  7. Installs preconfigured extensions directly into <InstallDir>\data\extensions.

Understanding Portable Mode

When a data\ folder exists alongside Code.exe or VSCodium.exe, the editor runs in official Portable Mode:

Data TypeLocation
User Settings (settings.json)<InstallDir>\data\user-data\User\settings.json
Keybindings & Snippets<InstallDir>\data\user-data\User\
Installed Extensions<InstallDir>\data\extensions\
Cache & Workspace State<InstallDir>\data\user-data\

Nothing is written to %APPDATA%\Code or %USERPROFILE%\.vscode, making it easy to move, back up, or run multiple editions side by side.


Next Steps

Configuration (config.ini & editor.ini)

Configuration is intentionally split into manager configuration (config.ini) and editor configuration (editor.ini + optional profiles\*.ini files).


config.ini Reference

Leave any [General] option blank to be prompted interactively at runtime. Command-line flags override config.ini.

[General]

KeyValid ValuesDescription
DefaultInstallDirPath template (supports {program_name})Where portable editors are installed (e.g., D:\IDE\{program_name} expands to D:\IDE\VSCode, D:\IDE\VSCodium-Insiders). Leave blank to prompt.
DefaultToolsDirPath template (supports {tool_name})Where portable extension dependencies are installed (e.g., D:\CLI\{tool_name} expands to D:\CLI\Git, D:\CLI\Ripgrep, D:\CLI\Python).
DefaultProductvscode | vscodium | blankDefault editor distribution.
DefaultChannelstable | insiders | blankDefault release channel.
AutoAddContextMenutrue | false | blankAutomatically register Explorer right-click context menus on install.
AutoAddPathtrue | false | blankAutomatically add <InstallDir>\bin to User PATH on install.
AutoConfigureSettingstrue | false | blankAutomatically apply resolved INI settings to settings.json on install.
OverwriteExistingSettingsfalse (default) | truefalse performs a non-destructive merge (keeps existing user values and only adds missing keys). true updates conflicting keys from your INI files. Always saves settings.json.bak before editing an existing file.
AutoInstallExtensionstrue | false | blankAutomatically install extensions loaded from [Extensions] in configured profiles / editor.ini.
AutoInstallDependenciestrue | false | blankAutomatically install missing portable software dependencies required by extensions (with PATH & official HKCU registry entries).

[Profiles]

KeyValid ValuesDescription
OptionalProfilesBlank, single name, comma-separated names, or .ini path(s)Optional profiles from profiles\ to load (in order). Leave blank to load zero optional profiles. Example: portable-essentials, privacy, no-ai, low-end, ext-general.
EditorConfigFileRelative/absolute .ini path or blankPath to your personal editor config file (default: editor.ini). Leave blank to skip.

[Logging]

KeyValid ValuesDescription
LogRetentionDaysPositive integer (default: 30)Days to keep daily log files in logs\ before automatic pruning.
LogFilePrefixString or blankCustom filename prefix for logs\<prefix>-YYYY-MM-DD.log. Leave blank to automatically use the project folder name (vscode-portable-manager-YYYY-MM-DD.log).

editor.ini Reference

Your personal editor configuration file (opened via main.bat Option 9) is loaded only when EditorConfigFile is set in config.ini.

[Profile]
Name = Personal Editor Configuration
Description = My custom portable VS Code / VSCodium defaults.

[Settings]
update.mode = none
update.showReleaseNotes = false
editor.fontSize = 14
editor.fontFamily = "JetBrains Mono, Consolas, monospace"
files.autoSave = afterDelay
files.autoSaveDelay = 1000
files.watcherExclude = {"**/node_modules/**": true, "**/dist/**": true}

[Extensions]
editorconfig.editorconfig
ms-vscode.powershell

[Dependencies]
# Optional explicit tool IDs to check/install portably (e.g. git, ripgrep, python)

Supported Value Types Under [Settings]

INI SyntaxWritten to settings.json As
true / falseJSON boolean (true / false)
14, 1000, 1.5JSON number
none, afterDelayJSON string
"14", "Consolas, monospace"Quoted string (forces string type and preserves whitespace/quotes)
\n, \r\nNewline escape string (useful for files.eol = \n)
{"*": false} or ["*.tmp"]Parsed JSON object or array (deep-merged for nested objects!)

Dynamic Path Tokens Under [Settings]

Any string value under [Settings] supports automatic path tokens expanded at write time:

TokenExpands To
{install_dir}Absolute portable editor install directory (e.g., D:\IDE\VSCode)
{data_dir}<InstallDir>\data
{ripgrep_path}Verified rg.exe path (prefers standalone portable/PATH rg.exe, falls back to editor-bundled rg.exe)

Layering & Precedence Order

When multiple INI files are active, settings are merged in strict deterministic order (later layers override earlier ones):

  1. Existing data\user-data\User\settings.json (preserved unless OverwriteExistingSettings = true or -Overwrite)
  2. OptionalProfiles in the exact order listed in config.ini (or -Preset)
  3. EditorConfigFile (editor.ini) — always overrides optional profiles
  4. Auto-wired portable dependency paths (todo-tree.ripgrep.ripgrep, git.path, clangd.path, cmake.cmakePath, shellcheck.executablePath, python.defaultInterpreterPath)
  5. Interactive wizard edits (when using configure.ps1 Option 3)

Optional Profiles & Extension Packs (profiles\*.ini)

All optional profiles live as clean, active (uncommented) .ini files inside profiles\. They are never loaded unless you explicitly enable them in config.ini (OptionalProfiles), pass -Preset on the CLI, or pick them interactively in configure.ps1.


Built-In Settings Profiles

Profile NameFileSummary
portable-essentialsprofiles/portable-essentials.iniMinimal portable defaults: sets update.mode = "none" and update.showReleaseNotes = false so updates remain cleanly managed by update.ps1.
privacyprofiles/privacy.iniPortable essentials + disables telemetry, feedback prompts, experiments, and Bing-backed natural language settings search.
no-aiprofiles/no-ai.iniDisables built-in AI features (chat.disableAIFeatures = true), chat command center, agent mode, inline ghost-text suggestions, and GitHub Copilot (github.copilot.enable = {"*": false}, auto-completions, next-edit suggestions).
low-endprofiles/low-end.iniPerformance tuning for low-end / older hardware: disables minimap, smooth scrolling, caret animations, sticky scroll, CodeLens, inlay hints, semantic highlighting, bracket colorization, terminal GPU acceleration, auto-fetch/refresh, and adds heavy folder exclusions to files.watcherExclude.
recommendedprofiles/recommended.iniBalanced portable developer setup: portable essentials + privacy off + sensible editor, autosave, whitespace, terminal, and Git defaults.

Built-In Extension Pack Profiles

Profile NameFileIncluded ExtensionsRequired Portable Dependencies
ext-generalprofiles/ext-general.iniEditorConfig, GitLens, Git Graph, Markdown All in One, Error Lens, Todo Tree (+ sets todo-tree.ripgrep.ripgrep = {ripgrep_path})git, ripgrep
ext-webprofiles/ext-web.iniESLint, Prettier, Tailwind CSS, Auto Rename Tag, Path Intellisense, Live Servernode
ext-pythonprofiles/ext-python.iniPython, Ruff, Jupyter, Even Better TOMLpython
ext-cppprofiles/ext-cpp.iniclangd, CMake, CMake Tools, CodeLLDBclangd, cmake, ninja
ext-rustprofiles/ext-rust.inirust-analyzer, Even Better TOML, CodeLLDBrust
ext-devopsprofiles/ext-devops.iniDocker, YAML, Terraform, PowerShell, ShellCheckdocker (manual), terraform, pwsh, shellcheck

Combining Multiple Profiles

List multiple profiles separated by commas in config.ini:

[Profiles]
OptionalProfiles = portable-essentials, privacy, no-ai, low-end, ext-general, ext-python
EditorConfigFile = editor.ini
  • Later profiles override earlier profiles if both define the same [Settings] key.
  • Nested objects (such as files.watcherExclude) are deep-merged.
  • Extension lists across multiple ext-* profiles are automatically deduplicated (for example, tamasfe.even-better-toml in both ext-python and ext-rust is installed once).
  • editor.ini always has the final word over every optional profile.

Creating Your Own Drop-In Profile

Drop any .ini file into profiles\ (for example, profiles\my-work.ini):

[Profile]
Name = My Work Setup
Description = Company formatting rules and Go toolchain.

[Settings]
editor.tabSize = 2
editor.formatOnSave = true

[Extensions]
golang.go
editorconfig.editorconfig

[Dependencies]
go
git

It is automatically discovered by configure.ps1 and can be referenced immediately via OptionalProfiles = my-work or -Preset my-work without modifying any scripts.

CLI Reference

All four scripts under src\ require PowerShell 7.x (pwsh.exe) and can be called directly for scripting or automation.


src\install.ps1 — Fresh Portable Install

Downloads, extracts, enables Portable Mode, integrates Explorer/PATH, installs missing portable dependencies, writes settings.json, and installs extensions.

pwsh -NoProfile -ExecutionPolicy Bypass -File src\install.ps1 [options]
ParameterTypeDescription
-ScriptRootstringOverride project root directory (auto-detected if omitted).
-TargetDirstringExplicit installation path (overrides DefaultInstallDir).
-Productvscode | vscodiumOverride DefaultProduct.
-Channelstable | insidersOverride DefaultChannel.
-PresetstringComma-separated optional profile name(s) or .ini path(s) (overrides OptionalProfiles).
-SkipContextMenuswitchDo not register Explorer context menus.
-SkipPathswitchDo not add bin\ to User PATH.
-SkipSettingsswitchDo not modify settings.json.
-SkipExtensionsswitchDo not install preconfigured extensions.
-SkipDependenciesswitchCheck dependencies without installing missing portable tools.
-InstallDependenciesswitchAuto-install missing portable dependencies without prompting.
-OverwriteSettingsswitchOverwrite conflicting existing keys in settings.json.
-ForceswitchSkip confirmation if target directory already contains an editor.

src\update.ps1 — In-Place Binary Update

Updates editor binaries in-place while preserving the entire portable data\ folder (settings, extensions, workspace state).

pwsh -NoProfile -ExecutionPolicy Bypass -File src\update.ps1 [options]
ParameterTypeDescription
-ScriptRootstringOverride project root directory.
-TargetDirstringTarget portable folder (auto-discovers if omitted).
-ForceswitchSkip update confirmation and up-to-date tag check prompts.

src\configure.ps1 — Standalone Configurator

Interactive dashboard and non-interactive CLI for managing existing portable installations.

pwsh -NoProfile -ExecutionPolicy Bypass -File src\configure.ps1 [options]
ParameterTypeDescription
-ScriptRootstringOverride project root directory.
-TargetDirstringTarget portable folder (auto-discovers if omitted).
-ModestringInteractive (default), Status, Settings, AddContextMenu, RemoveContextMenu, AddPath, RemovePath, InstallExtensions, CheckDependencies, ExportProfile, ImportProfile.
-PresetstringOptional profile name(s) or .ini path(s) for Settings, InstallExtensions, or CheckDependencies.
-ProfilePathstringJSON bundle path for ExportProfile / ImportProfile.
-OverwriteswitchOverwrite conflicting keys in settings.json.
-SkipDependenciesswitchSkip installing missing portable dependencies.
-InstallDependenciesswitchAuto-install missing portable dependencies without prompting.

Examples

# Inspect installation health (version, portable data, context menus, PATH, settings, extensions)
pwsh -File src\configure.ps1 -TargetDir "D:\IDE\VSCode" -Mode Status

# Apply low-end + no-ai profiles non-interactively
pwsh -File src\configure.ps1 -TargetDir "D:\IDE\VSCode" -Mode Settings -Preset "low-end,no-ai" -Overwrite

# Check and install missing portable dependencies for installed + configured extensions
pwsh -File src\configure.ps1 -TargetDir "D:\IDE\VSCode" -Mode CheckDependencies -InstallDependencies

# Export settings.json + installed extensions list to a portable JSON backup
pwsh -File src\configure.ps1 -TargetDir "D:\IDE\VSCode" -Mode ExportProfile -ProfilePath ".\my-backup.json"

# Restore backup onto a fresh portable installation
pwsh -File src\configure.ps1 -TargetDir "D:\IDE\VSCodium" -Mode ImportProfile -ProfilePath ".\my-backup.json"

src\uninstall.ps1 — Removal & Cleanup

Auto-discovers portable installations (including stale registry/PATH leftovers of manually deleted folders) for clean removal.

pwsh -NoProfile -ExecutionPolicy Bypass -File src\uninstall.ps1 [options]
ParameterTypeDescription
-ScriptRootstringOverride project root directory.
-TargetDirstringExplicit folder to clean up/uninstall.
-RegistryOnlyswitchRemove context menus, MuiCache entries, and User PATH entries while keeping all files on disk.
-ForceswitchSkip per-target confirmation prompts.

Extension Dependencies & Portable Toolchains

Many VS Code and VSCodium extensions depend on external CLI binaries or language toolchains. To keep your entire setup 100% portable, the manager automatically checks required software before installing extensions (or on demand via configure.ps1 -Mode CheckDependencies / Option 11).


How Detection Works

For each required tool, Test-DependencyInstalled checks in order:

  1. System & User PATH (automatically ignores Microsoft Store’s 0-byte WindowsApps\python.exe stub alias).
  2. Windows App Paths registry (HKCU and HKLM).
  3. Official program registry keys (HKCU / HKLM, including PEP 514 Software\Python\PythonCore).
  4. Your configured DefaultToolsDir (e.g., D:\CLI\{tool_name}). If a portable copy already exists there without PATH/registry registration, the manager automatically repairs its PATH and official HKCU registry keys.

Supported Portable Toolchains

Every portable tool is downloaded directly from its official upstream Windows x64 release, extracted into DefaultToolsDir (e.g., D:\CLI\<ToolName>), added to User PATH (and the active process PATH with WM_SETTINGCHANGE broadcast), and registered under its official per-program HKCU registry keys:

Tool IDTriggered By ExtensionsOfficial Portable SourceOfficial HKCU Registry Keys WrittenAuto-Wired settings.json Key
gitgitlens, git-graph, githistory, gitblame, vscode-pull-request-githubgit-for-windows/git (MinGit-*-64-bit.zip)Software\GitForWindows + App Paths\git.exegit.path
ripgrepgruntfuggly.todo-treeBurntSushi/ripgrep (x86_64-pc-windows-msvc.zip)Software\ripgrep + App Paths\rg.exetodo-tree.ripgrep.ripgrep
nodevscode-eslint, prettier-vscode, vscode-tailwindcss, vitest.explorer, playwrightOfficial nodejs.org latest LTS win-x64.zipSoftware\Node.js + App Paths\node.exe(via PATH)
pythonms-python.python, vscode-pylance, debugpy, jupyterOfficial NuGet python .nupkg (tools\) + ensurepipSoftware\Python\PythonCore\<X.Y> (PEP 514) + App Paths\python.exepython.defaultInterpreterPath
cmaketwxs.cmake, ms-vscode.cmake-tools, ms-vscode.cpptoolsKitware/CMake (windows-x86_64.zip)Software\Kitware\CMake + App Paths\cmake.execmake.cmakePath
ninjams-vscode.cmake-tools, ms-vscode.cpptoolsninja-build/ninja (ninja-win.zip)Software\Ninja + App Paths\ninja.exe(via PATH)
clangdllvm-vs-code-extensions.vscode-clangdclangd/clangd (clangd-windows-*.zip)Software\LLVM\clangd + App Paths\clangd.execlangd.path
rustrust-lang.rust-analyzerOfficial rustup-init.exe with portable CARGO_HOME & RUSTUP_HOMESoftware\Rust + App Paths\rustc.exe, cargo.exe(via PATH + env vars)
gogolang.goOfficial go.dev/dl stable windows-amd64.zip + GOROOTSoftware\GoProgrammingLanguage + App Paths\go.exe(via PATH + GOROOT)
terraformhashicorp.terraformHashiCorp Checkpoint + windows_amd64.zipSoftware\HashiCorp\Terraform + App Paths\terraform.exe(via PATH)
shellchecktimonwong.shellcheckkoalaman/shellcheck (shellcheck-v*.zip)Software\ShellCheck + App Paths\shellcheck.exeshellcheck.executablePath
pwshms-vscode.powershellPowerShell/PowerShell (win-x64.zip)Software\PowerShell + App Paths\pwsh.exe(via PATH)
ghgithub.vscode-pull-request-githubcli/cli (gh_*_windows_amd64.zip)Software\GitHub\CLI + App Paths\gh.exe(via PATH)
dockerms-azuretools.vscode-docker(Non-portable: requires Windows service / WSL2 daemon)Detected & reported with manual install instructions—

Controlling Automatic Dependency Installs

In config.ini:

[General]
DefaultToolsDir = D:\CLI\{tool_name}
AutoInstallDependencies = true   # true | false | blank (prompt Y/S/N)

You can also declare explicit tool requirements in any profile or editor.ini via [Dependencies]:

[Dependencies]
git
ripgrep
python

Troubleshooting


PowerShell 7 (pwsh.exe) Not Found

Symptom: main.bat reports [ERROR] PowerShell 7 (pwsh.exe) was not found in PATH, or running a .ps1 script directly fails with a version error.

Cause: All entrypoints include #Requires -Version 7.0 and do not support legacy Windows PowerShell 5.1 (powershell.exe).

Fix:

winget install Microsoft.PowerShell

Close and reopen your terminal so pwsh.exe is in PATH.


Todo Tree: Failed to find vscode-ripgrep

Symptom: Todo Tree displays:

Todo-Tree: Failed to find vscode-ripgrep - please install ripgrep manually and set 'todo-tree.ripgrep' to point to the executable

Cause:

  1. Newer VS Code builds moved bundled ripgrep to @vscode/ripgrep-universal, breaking Todo Tree’s built-in lookup.
  2. Todo Tree’s error message is outdated: "todo-tree.ripgrep" is a parent namespace object in its schema, so VS Code ignores a string value there. The actual setting key is "todo-tree.ripgrep.ripgrep".

Fix: Run the dependency check against your portable install:

pwsh -File src\configure.ps1 -Mode CheckDependencies -InstallDependencies

This installs portable ripgrep (rg.exe), adds it to PATH and HKCU\Software\ripgrep, removes any invalid "todo-tree.ripgrep" string key, writes "todo-tree.ripgrep.ripgrep", and takes effect after reloading the VS Code window (Ctrl+Shift+P → Developer: Reload Window).


Newly Added PATH Entries Aren’t Seen in Already-Open Terminals

Cause: Windows processes inherit PATH when launched. Although the manager broadcasts WM_SETTINGCHANGE, already-running terminals and some Explorer-launched processes do not reload PATH until restarted.

Fix:

  • Open a new terminal window (new shells pick up the updated User PATH).
  • For editor extensions (git, ripgrep, clangd, cmake, shellcheck, python), the manager also writes explicit executable paths into data\user-data\User\settings.json so they work immediately without restarting Explorer.

uninstall.ps1 or update.ps1 Reports Locked Files

Cause: An editor window, background extension host, or open terminal is still holding handles inside the installation folder.

Fix: Both update.ps1 and uninstall.ps1 automatically terminate running editor processes strictly inside <InstallDir>\. If external processes (such as a shell whose current directory is inside <InstallDir>) hold a lock, close those shells and re-run the command.


GitHub API Rate Limit (HTTP 403)

Symptom: Installing VSCodium or a GitHub-hosted portable dependency fails with 403 rate limit exceeded.

Cause: Unauthenticated GitHub API requests are limited to 60 requests/hour per IP address.

Fix: Wait for the rate-limit window to reset, or retry later.


Inspecting Verbose Daily Logs

Every action appends complete diagnostics (SESSION START, loaded INI files, HTTP redirects/sizes, registry keys written/deleted, settings merges, stack traces, and SESSION END) to:

logs\<prefix>-YYYY-MM-DD.log

Open the logs folder directly from main.bat (Option 7 — Open Logs Folder). Remember to redact personal usernames/paths before sharing logs publicly.

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>.

Module & Function API Reference

Function-level reference for all library modules under src\event\, src\utility\, and src\core\.


src\event\progress.ps1

FunctionDescription
Test-ConsoleInteractiveSafely detects whether stdout is an interactive console (prevents exceptions when output is redirected/piped).
Clear-ProgressLineErases any active inline progress bar before printing a console log line.
Show-WgetProgress -Task -Percent [-Stats] [-ThrottleMs 75] [-Complete]Renders a throttled wget/docker-style inline progress bar with elapsed mm:ss timer.

src\event\logger.ps1

FunctionDescription
Resolve-ProjectRoot [-ScriptRoot]Resolves {ROOT} from argument or two parent levels above src\event\.
Invoke-LogPruning -LogsDir [-RetentionDays 30]Deletes *.log files older than RetentionDays; returns List[string] of pruned filenames (via unary ,).
Initialize-Logger [-ScriptRoot] [-Component] [-RetentionDays] [-LogPrefix] [-Context]Creates logs\, prunes expired logs, opens logs\<prefix>-YYYY-MM-DD.log, and writes a full SESSION START banner.
Get-CurrentLogFilePathReturns the active daily log file path.
Write-Log -Message [-Level]Writes timestamped [file:line] entry to the log file; prints INFO/WARN/ERROR/SUCCESS to console (DEBUG/TRACE are file-only).
Write-ExceptionLog -ErrorRecord [-Context]Logs exception message (ERROR) plus exception type, inner exception, invocation position, and ScriptStackTrace (DEBUG).
Close-Logger [-Status]Writes SESSION END footer with elapsed duration.

src\utility\filesystem.ps1

FunctionDescription
Invoke-FileDownloadWithProgress -Uri -OutFile [-TaskLabel] [-TimeoutMinutes 15]Streams HTTPS downloads via System.Net.Http.HttpClient into a .part temp file, atomically moves to $OutFile, and logs resolved URI, HTTP status, size, speed, and duration.
Expand-ZipWithProgress -ZipPath -DestinationPath [-PreserveData] [-StripSingleTopDir] [-OnlyUnderPrefix] [-TaskLabel]Extracts .zip / .nupkg archives via System.IO.Compression.ZipFile with strict Zip Slip protection, optional data\ preservation, single-root flattening, and prefix extraction.
Remove-FolderWithProgress -FolderPath [-TaskLabel]High-speed .NET [System.IO.Directory]::EnumerateFiles / [System.IO.File]::Delete deletion with read-only attribute clearing and rd /s /q fallback.
Stop-EditorProcessesInDir -InstallDir [-ProcessNames]Stops running editor processes strictly inside $InstallDir\.

src\utility\path.ps1

FunctionDescription
Send-EnvironmentChangeBroadcastBroadcasts WM_SETTINGCHANGE ("Environment") via user32.dll SendMessageTimeout.
Test-UserPathDirectory -DirectoryCase-insensitive, trailing-slash-normalized check for any directory in User PATH.
Add-UserPathDirectory -Directory [-AlsoUpdateProcessPath]Deduplicated User PATH append + optional live $env:Path prepend + broadcast.
Test-UserPathEntry -TargetDirChecks <TargetDir>\bin in User PATH.
Add-UserPathEntry -TargetDirAdds <TargetDir>\bin to User PATH and current process PATH.
Remove-UserPathEntry -TargetDirRemoves exact $TargetDir or $TargetDir\* entries from User PATH.

src\utility\registry.ps1

FunctionDescription
Test-RegistryValueMatchesDir -Value -InstallDirDirectory-boundary-safe regex check preventing sibling path collisions.
Add-ContextMenu -InstallDir [-Profile]Registers 4 Explorer shell context menus (*, Directory, Directory\Background, Drive) under HKCU\Software\Classes via .NET Registry API.
Test-ContextMenu -InstallDir [-Profile]Returns registration count (RegisteredCount/TotalCount, IsComplete, Details).
Find-EditorPathsInRegistryTargeted non-recursive .NET scan across HKCU/HKLM shell keys, Applications, and App Paths.
Remove-ContextMenuAndReg -InstallDirDeletes matched shell keys and MuiCache entries referencing $InstallDir.
Add-ToolAppPathRegistry -ExePath [-ExtraPathDirs]Writes HKCU\Software\Microsoft\Windows\CurrentVersion\App Paths\<exe>.
Add-PythonPep514Registry -PythonDir -VersionWrites PEP 514 HKCU\Software\Python\PythonCore\<X.Y> and InstallPath keys.
Set-ProgramSoftwareRegistryKey -SubKey -ValuesWrites values directly under HKCU\Software\<OfficialProgramName>.
Get-ProgramSoftwareRegistryValue -SubKey [-ValueName]Reads a program registry value from HKCU or HKLM.
Find-ToolInAppPathsRegistry -ExeNameResolves an executable from HKCU/HKLM App Paths.

src\core\config.ps1

FunctionDescription
ConvertFrom-IniTypedValue -RawValueParses INI values into PowerShell booleans, longs, doubles, strings, newline escapes, or JSON objects/arrays (ConvertFrom-Json -AsHashtable).
Resolve-ConfigBool -ValueConverts true/1/yes/on → $true, false/0/no/off → $false, blank → $null.
Resolve-IniFilePath -NameOrPath -ScriptRoot [-SearchProfilesDir]Resolves profile names or relative/absolute .ini paths.
Import-EditorIniFile -PathParses [Profile], [Settings], [Extensions], and [Dependencies] from any profile or editor .ini.
Get-ManagerConfig [-ScriptRoot]Parses config.ini and loads only referenced OptionalProfiles and EditorConfigFile.
Write-ConfigDiagnosticLog -ConfigLogs full loaded config, profiles, and counts at DEBUG level.
Get-TargetDir -ProvidedPath -Config [-Profile] [-PromptText]Expands {program_name} and resolves target installation directory.

src\core\edition.ps1

FunctionDescription
Get-EditorProfile -Product -ChannelReturns metadata hashtable for vscode/vscodium × stable/insiders.
Get-AllEditorProfilesReturns all 4 edition profiles.
Select-EditorProfile [-Config] [-CliProduct] [-CliChannel]Resolves or interactively prompts for product & channel.
Resolve-PackageDownloadInfo -ProfileReturns { Url; Tag; AssetName } from Microsoft direct endpoint or GitHub Releases API.
Get-InstalledEditorProfile -InstallDirDetects installed edition from executable filename.
Get-InstalledEditorVersion -InstallDirReads version from package.json, product.json, commit-hash-nested package.json, or PE FileVersionInfo.
Test-PortableMode -InstallDirReturns $true if <InstallDir>\data exists.
Get-EditorCliPath -InstallDir [-Profile]Locates <InstallDir>\bin\<cli>.cmd.
Find-BundledRipgrepPath -InstallDirPrefers standalone rg.exe (PATH, App Paths, HKCU\Software\ripgrep), falling back to @vscode\ripgrep-universal, legacy @vscode\ripgrep, and commit-hash layouts.

src\core\discovery.ps1

FunctionDescription
Find-VSCodeInstalls [-Config] [-IncludeMissing]Auto-discovers portable installations across .NET Registry, User PATH, running processes, and expanded DefaultInstallDir, excluding standard non-portable system/user installers.
Format-InstallBadges -InstallFormats version, portable, context menu, and PATH status badges.
Select-DiscoveredInstall -Discovered [-PromptTitle] [-AllowManualEntry]Interactive installation picker shared by update.ps1, configure.ps1, and uninstall.ps1.

src\core\settings.ps1

FunctionDescription
Get-SettingsSchemaReturns the curated interactive wizard schema across all categories (Portable & Updates, Privacy & Telemetry, AI & Copilot, Performance (Low-End), Editor, Files, Workbench & UI, Terminal, Git).
Get-SettingsPresets [-ScriptRoot]Dynamically loads every profiles\*.ini file via Import-EditorIniFile.
ConvertFrom-Jsonc -RawTextString-literal-safe JSONC comment (//, /* */) and trailing-comma stripper + ConvertFrom-Json -AsHashtable.
Read-EditorSettings -InstallDir / Write-EditorSettings -InstallDir -SettingsReads/writes UTF-8 (no BOM) deterministically sorted data\user-data\User\settings.json with automatic .bak backup.
Merge-SettingsHashtable -Base -Overlay [-OverwriteExisting]Recursive deep merger tracking Added, Updated, and Preserved counts.
Resolve-ConfiguredSettings [-Config] [-PresetName] [-ExtraOverrides] [-ScriptRoot]Layers optional profile INI(s) → EditorConfigFile → inline fallback → runtime overrides; returns { Settings; Extensions; Dependencies; Sources }.
Expand-SettingsTokens -Settings -InstallDirExpands {ripgrep_path}, {install_dir}, and {data_dir} in string values.
Apply-EditorSettings -InstallDir -OverlaySettings [-OverwriteExisting]Expands tokens, merges into existing settings.json, and writes to disk.
Select-OptionalPresetInteractive [-ScriptRoot] / Invoke-InteractiveSettingsWizard -InstallDirInteractive menus used by configure.ps1 and install.ps1.

src\core\dependencies.ps1

FunctionDescription
Get-DependencyCatalogDefinitions for all supported tools (Git, ripgrep, Node.js, Python 3, CMake, Ninja, clangd, Rust, Go, Terraform, ShellCheck, PowerShell 7, Docker).
Get-ExtensionDependencyMapMaps VS Code / VSCodium extension IDs to required tool IDs.
Get-RequiredDependenciesForExtensions [-Extensions] [-ExtraDependencies]Deduplicates required tool IDs with their requesting extension reasons.
Test-DependencyInstalled -ToolId [-Config]Multi-source check (PATH skipping WindowsApps Python stubs, App Paths, official Software\* / PEP 514 registry, DefaultToolsDir).
Resolve-ToolDownloadInfo -ToolQueries official GitHub Releases, nodejs.org, NuGet v3, HashiCorp Checkpoint, go.dev, or rustup-init.
Register-PortableToolEnvironmentAndRegistry -Tool -InstallDir [-Version]Registers User + process PATH, App Paths\<exe>, and official HKCU\Software\<Program> keys.
Install-PortableDependency -ToolId [-Config]Downloads, extracts, bootstraps (ensurepip for Python / portable rustup-init for Rust), and registers a portable tool.
Get-DependencyExecutableSettingsPatch -RequiredMap [-Config]Builds the settings.json executable path patch (todo-tree.ripgrep.ripgrep, git.path, etc.).
Invoke-DependencyCheckAndInstallFull dependency audit, interactive/automatic portable installation, existing portable tool registration repair, legacy key cleanup, and settings.json wiring.

Extending the Manager

Step-by-step guides for adding new profiles, portable dependencies, editor editions, or settings schema entries.


1. Adding a New Optional Profile (profiles\*.ini)

No PowerShell changes are required. Create a new .ini file inside profiles\:

[Profile]
Name = Extensions: Go Development
Description = Official Go extension and portable Go toolchain.

[Settings]
go.toolsManagement.autoUpdate = true

[Extensions]
golang.go

[Dependencies]
go

Because Get-SettingsPresets scans profiles\*.ini dynamically:

  • It immediately appears in configure.ps1 Option 2.
  • It can be referenced via OptionalProfiles = ext-go in config.ini or -Preset ext-go on the CLI.
  • Update the profile list comments in config.ini, README.txt, and docs/user/profiles.md if contributing it as a built-in profile.

2. Adding a New Portable Software Dependency

Edit src/core/dependencies.ps1:

  1. Add the tool specification to Get-DependencyCatalog:
    • Use an official upstream Windows x64 portable archive (GitHub Release .zip or official JSON API).
    • Set StripSingleTopDir = $true if the archive wraps all files inside a versioned top-level directory.
    • Set SoftwareRegKey to the tool’s official Windows registry key under Software\<VendorOrProgram> (never invent a manager-specific namespace).
  2. Map extension IDs in Get-ExtensionDependencyMap:
    "publisher.extension-id" = @("my-tool")
    
  3. Add resolver logic in Resolve-ToolDownloadInfo (if not using standard "GitHubZip").
  4. Add official registry writes in Register-PortableToolEnvironmentAndRegistry under switch ($Tool.Id):
    "my-tool" {
        $null = Set-ProgramSoftwareRegistryKey -SubKey "Software\Vendor\MyTool" -Values @{
            InstallDir = $CleanDir
            Version    = $Version
        }
    }
    
  5. (Optional) Auto-wire the executable path into settings.json:
    • If the extension has an explicit binary-path setting (verify its exact package.json key!), add it to $ToolSettingKeyMap in both Get-DependencyExecutableSettingsPatch and Invoke-DependencyCheckAndInstall.
  6. Document it in README.txt and docs/user/dependencies.md.

3. Adding a New Setting to the Interactive Wizard

Edit Get-SettingsSchema in src/core/settings.ps1:

@{
    Key         = "editor.rulers"
    Category    = "Editor"
    Type        = "string"
    Default     = "[80, 120]"
    ValidValues = @()
    Description = "Vertical ruler column positions"
}

4. Adding a New Editor Edition

Edit src/core/edition.ps1:

  1. Add the edition metadata hashtable to Get-EditorProfile and Get-AllEditorProfiles (Product, Channel, DisplayName, ProgramName, ExeName, CliCmd, ProcessName, RegistryKey, MenuLabel, SourceType, endpoint info).
  2. Add executable detection in Get-InstalledEditorProfile (place more specific names like *- Insiders.exe before base names).
  3. Update the executable regex in Find-EditorPathsInRegistry (src\utility\registry.ps1) and process lists in Find-VSCodeInstalls (src\core\discovery.ps1) and Stop-EditorProcessesInDir (src\utility\filesystem.ps1).

Release Packaging Guide

This repository separates GitHub repository / documentation files from standalone runtime release files so .github/workflows/release.yml produces a clean, minimal .zip archive for end users.


Automated Release Workflow

Releases are packaged and published automatically by .github/workflows/release.yml:

  • Tag Push (v*.*.*): Pushing a semantic version tag (e.g., git tag v1.0.0 && git push origin v1.0.0) validates syntax, stages strictly the runtime allowlist, builds vscode-portable-manager-<tag>.zip + .sha256, uploads workflow artifacts, and publishes a GitHub Release using secrets.PAT_TOKEN (with secrets.GITHUB_TOKEN fallback). Tags containing - (e.g., v1.1.0-beta.1) are automatically marked as prereleases.
  • Manual Dry Run (workflow_dispatch): Trigger from the GitHub Actions tab with dry_run: true to build and download the .zip + .sha256 artifacts without publishing a release.

Release Archive Contents (vscode-portable-manager-vX.Y.Z.zip)

Included in Release .zip (Strict Allowlist)

PathPurpose in Packaged Release
README.txtStandalone plain-text user guide (replaces README.md and docs\ inside the ZIP)
main.batInteractive Windows launcher
config.iniClean generic default manager configuration
editor.iniClean starter personal editor configuration
profiles\*.iniAll built-in optional settings and extension pack profiles
src\**All 4 CLI entrypoints + core\, event\, and utility\ modules

Excluded from Release .zip (Enforced by Staging Audit)

The workflow actively fails the build if any of the following leak into the staged archive:

  • *.md (README.md, ROADMAP.md, CHANGELOG.md, SECURITY.md, PRIVACY.md, CONTRIBUTING.md, CODE_OF_CONDUCT.md)
  • docs\**
  • .github\**, .git\**, .gitignore
  • logs\** (auto-created on first run)
  • plan.txt

Pre-Tag Checklist

  1. Ensure config.ini contains generic defaults (D:\tools\{program_name}, D:\tools\{tool_name}, blank OptionalProfiles, EditorConfigFile = editor.ini, blank LogFilePrefix).
  2. Confirm README.txt reflects any new CLI flags, profiles, or portable dependencies.
  3. Move items in CHANGELOG.md from [Unreleased] into the new version heading.
  4. Confirm CI (CI Validation & Tests) is green on main, then tag and push:
    git tag -a v1.0.0 -m "Release v1.0.0"
    git push origin v1.0.0