ClashByShell

Native Windows MSI packaging (v1.2.5)

The release format is a native Windows Installer package for each of x86, x64 and ARM64. Windows runs MSI through its native msiexec.exe; no emulated setup bootstrapper is included. Existing historical portable ZIP downloads are retained, but new releases do not publish portable ZIPs.

Installed layout

Relative path Purpose
ClashByShell.exe Native command-line program, static release MSVC CRT
ClashByShellUI.exe Matching native interactive menu and desktop shortcut target, static release MSVC CRT
ClashByShellMaintenance.exe Matching native offline installation/uninstallation utility (no portable-data import)
bin/MihomoService.exe Matching native TUN helper
bin/mihomo.exe Latest stable upstream native Mihomo for the selected architecture, pinned once per CI run
bin/curl.exe Native curl built from locked upstream source; see dependency lock for enabled features and TLS backend
bin/Loopback.exe Locked source, net10.0-windows self-contained single-file for the selected RID
resources/ui/xd Locked public MetaCubeXD dashboard
resources/{geoip.dat,geosite.dat,Country.mmdb,ASN.mmdb} Locked standard public Geo data
licenses Redistributed licenses, corresponding-source archives, build modifications and PE import report
dependencies.lock.json Input versions, HTTPS sources and actual cryptographic hashes
build-manifest.json, SHA256SUMS Source commit, architecture, build metadata and installed-payload hashes

Private SQLite databases, YAML, subscriptions, TUN intent, backups and caches are not installer inputs. They live under the current user’s %APPDATA%\ClashByShell data root, bound to the installation directory. The current user, SYSTEM and Administrators may write this root; the protected program directory is not made writable by all users. Command-line program, menu UI, helper and maintenance utility must be upgraded together.

No aria2, execution-policy-changing launchers or old portable PowerShell maintenance entrypoints are installed. The MSI still installs per user to %LOCALAPPDATA%, but the package is elevated so install, repair and removal can stop SYSTEM processes and delete owned scheduled tasks; every such operation prompts UAC. The menu UI carries a requireAdministrator manifest, so Windows requests UAC before the process starts and the menu’s core operations run on an already elevated token. The command-line program stays asInvoker and requests UAC through runas only for start/stop/tun/status/proxy/pac; the elevated child writes its output to a %TEMP% file that the parent replays together with the exit code. The emergency PowerShell script uses Start-Process -Verb RunAs. No third-party elevation helper is bundled or used. Network maintenance uses native curl with certificate verification; no insecure TLS fallback is supplied. Loopback can extract bundled native .NET libraries into the .NET bundle cache on first use; single-file does not mean extraction-free.

Installation, upgrade and removal

Use the package matching the native operating-system architecture. ARM64 payloads must not substitute x64/x86 helper executables. Downgrades and incompatible existing installations are rejected rather than overwritten. The wizard allows an explicit installation directory, but has no portable-directory input or migration action. Silent installation cannot enable portable-data import either.

First use initializes the new independent database with no subscriptions and TUN disabled. Add subscriptions again in the new application. Old portable SQLite files, text subscriptions, YAML, binary caches and service/tun.status are never scanned or imported. Normal database schema initialization and supported schema upgrades remain available; an existing new-format database is not reset during upgrade or repair. The original portable directory is not modified or removed.

New tasks use stable names ClashByShell.Mihomo and ClashByShell.TunHelper. The application and installer do not look up, adopt, stop or delete legacy StartMihomoService / StartMihomoService2 tasks. Strict action/principal ownership checks still reject unrelated tasks occupying the new names. Close an old core before running the new one if it occupies the controller/proxy ports or TUN; installation does not perform automatic network cutover.

Upgrade/repair preserves private data. A matching ownership marker with safe ACLs is a supported retry/reinstall state, not an automatic reason to delete data. Uninstall displays an explicit checkbox confirming deletion of all private data belonging to this installation. Silent uninstall retains private data unless DELETEPRIVATE=1 is explicitly supplied. Major upgrades never use the private-data deletion action. Data deletion runs only as a commit action after a successful uninstall transaction. Unknown ownership, unsafe links, conflicting new-name tasks and running owned processes cause a failure rather than global termination or arbitrary recursive deletion. The original portable directory and other applications are not removed.

These packages are unsigned unless release notes explicitly state otherwise. SmartScreen or enterprise installation policies can warn or block installation. No signing certificate is fabricated or bundled.

Build and release gates

Build each target with scripts/build.ps1 -Architecture x86|x64|arm64 -WorkRoot <external directory>. The four outputs are main/ClashByShell.exe, ui/ClashByShellUI.exe, helper/MihomoService.exe and maintenance/ClashByShellMaintenance.exe. Package with scripts/package.ps1, passing the matching -MainExe, mandatory -UiExe, -HelperExe and -MaintenanceExe inputs, architecture, numeric version, pinned SDK and pinned WiX CLI. All intermediate files belong in the caller’s external WorkRoot. An existing download cache is read-only input: every item is hash-checked before copying. Each new CI build resolves the latest stable Mihomo release once before the architecture matrix, validates official SHA256 digests for all three Windows assets, and pins the matching license and corresponding-source archive. Resolution failure blocks the build; install-only reuses the original bundle. The checkout lock remains unchanged; the MSI contains the effective dependency lock and records Mihomo version/archive SHA256 in build-manifest.json. Local offline packaging can omit -MihomoManifestPath to use the checked-in lock. The effective dependency lock and scripts are the authoritative build recipe.

Packaging assembles a new whitelist-only stage, verifies every EXE/DLL PE machine and ordinary/delay import closure, rejects private databases/logs/credentials/reparse points and compiles a compressed MSI plus SHA256. All target executables and embedded installer actions must be native. Build-tool host architecture is not the product architecture.

Actions are manually dispatched, draft by default. The default diagnostic-build mode builds/tests/packages only x64 (another single architecture or all can be explicitly selected), then runs the disposable installer lifecycle. install-only requires a completed source run ID in this same repository and workflow and reuses its matching installer-bundle-<arch> artifact without rebuilding. It checks out lifecycle scripts at that run’s exact source commit; the initiating workflow’s separate validator first checks schema, workflow/repository/run/commit/version/architecture, exact file names, hashes, checksum sidecar, and source-script hashes. Legacy bundles without this identity contract are deliberately rejected. Source runs may have failed installation: each build uploads the reusable candidate MSI, SHA256, previous-version fixture, failure fixture, synthetic fixture tool and schema-3 manifest before installation begins. Schema-2 migration-era bundles are rejected by the new validator. The previous-version fixture contains the current payload with a lower synthetic version; it is not a historical release binary. The failure MSI is CI-only and embeds a compile-time deferred failure action after preparation; the production MSI must contain neither that action nor its test Binary. Artifacts expire after 14 days. Neither diagnostic mode can publish.

release-validate always forces all three architectures regardless of the architecture selection; only this mode can publish, and only after all build and install matrix jobs succeed. No automatic retries, scheduled builds or periodic quota-consuming work are configured.

Lifecycle tests cover independent first-install data, ignored portable inputs and legacy tasks, new-name foreign-task refusal, valid-marker retries, upgrade/repair preservation, uninstall retain/delete, and real deferred install/upgrade rollback. Synthetic new-format data is seeded directly by a restricted CI fixture, never by a migration command. Lifecycle runs request flushed verbose MSI logs (/L*V!) and opt into all four native maintenance diagnostics using only CBSINSTALLERDIAGNOSTICS=1. The native sink is the fixed protected ProgramData ClashByShellInstallerDiagnostics directory, with maintenance-<PID>-<16-hex-nonce>.log files. Each native log is capped at 64 KiB with a truncation marker and numeric tick/sequence/PID fields; these are structured diagnostics, not call stacks or crash dumps. The collector checks owner/ACLs, links, names and size limits and copies only new matching files; it never traverses the private data root for diagnostics. Failure artifacts contain explicit MSI logs, fixed-location ACL metadata, native diagnostic logs and a safe step/exit summary, never the synthetic database or private fixture directories. Runtime-failed installation remains a blocked gate until an actual disposable-runner validation succeeds.

Native x86 tests run on Windows x64; ARM64 tests require a real Windows ARM64 runner. Every matrix build, runtime test, package audit and disposable-VM installer lifecycle gate must pass before release permissions become available. A failed or missing target blocks the entire release. Release uploads only the three MSI packages and checksum files, verifies hashes again and refuses existing releases/tags. CI-only internal archives are not release products.

Local development does not install the MSI into the real workstation or touch existing private subscriptions. test-runtime.ps1 -SkipLifecycle explicitly omits the elevated ACL lifecycle fixture and prints a SKIP result; CI must not use this option, and passing local feature tests does not satisfy the installer lifecycle release gate. Installer lifecycle execution is restricted by the test script to a fresh disposable GitHub-hosted runner with no pre-existing ClashByShell data. A successful compile or PE audit alone is not a claim of successful installation or native runtime execution. Portable-era maintenance scripts, debug launchers and batch helpers are no longer kept in the source tree; the native maintenance utility is the only supported entrypoint and legacy entries are never included in the payload.