Skip to content

feat(installer): add standalone Windows .exe installer (vp-setup.exe)#1293

Draft
fengmk2 wants to merge 27 commits intomainfrom
windows-installer
Draft

feat(installer): add standalone Windows .exe installer (vp-setup.exe)#1293
fengmk2 wants to merge 27 commits intomainfrom
windows-installer

Conversation

@fengmk2
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 commented Apr 4, 2026

Add a standalone vp-setup.exe Windows installer binary that installs
the vp CLI without requiring PowerShell, complementing the existing
irm https://vite.plus/ps1 | iex script-based installer.

  • Create vite_setup shared library crate extracting installation logic
    (platform detection, registry queries, integrity verification, tarball
    extraction, symlink/junction management) from vite_global_cli
  • Create vite_installer binary crate producing vp-setup.exe with
    interactive prompts, silent mode (-y), progress bars, and Windows PATH
    modification via direct registry API (no PowerShell dependency)
  • Update vite_global_cli to use vite_setup instead of inline upgrade
    modules, ensuring upgrade and installer share identical logic
  • Add CI build/upload steps for installer in release workflow, attached
    as GitHub Release assets
  • Add RFC document at rfcs/windows-installer.md

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 4, 2026

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit 6153ccb
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/69d12f36b586850008481180

@fengmk2 fengmk2 self-assigned this Apr 4, 2026
Copy link
Copy Markdown
Member Author

fengmk2 commented Apr 4, 2026


How to use the Graphite Merge Queue

Add the label auto-merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

fengmk2 added 7 commits April 4, 2026 20:52
Add a standalone `vp-setup.exe` Windows installer binary that installs
the vp CLI without requiring PowerShell, complementing the existing
`irm https://vite.plus/ps1 | iex` script-based installer.

- Create `vite_setup` shared library crate extracting installation logic
  (platform detection, registry queries, integrity verification, tarball
  extraction, symlink/junction management) from `vite_global_cli`
- Create `vite_installer` binary crate producing `vp-setup.exe` with
  interactive prompts, silent mode (-y), progress bars, and Windows PATH
  modification via direct registry API (no PowerShell dependency)
- Update `vite_global_cli` to use `vite_setup` instead of inline upgrade
  modules, ensuring upgrade and installer share identical logic
- Add CI build/upload steps for installer in release workflow, attached
  as GitHub Release assets
- Add RFC document at rfcs/windows-installer.md
- Remove dirs_home() and dead fallback in resolve_install_dir(), use
  get_vp_home() directly
- Resolve install dir once in run() and pass through to all functions
- Extract read_current_version() into vite_setup as a public function,
  reuse in save_previous_version() and the installer
- Merge Cli/Options structs into single Options struct in cli.rs
- Extract replace_windows_exe() helper to eliminate copy-paste in
  setup_bin_shims()
- Remove unused LPWSTR type alias from windows_path.rs
- Remove excessive "Step N" comments
- Fix mixed path separator in interactive menu display
- Add interactive "Customize installation" submenu (option 2) allowing
  users to change version, registry, Node.js manager, and PATH settings
- Add env file creation via `vp env setup --env-only` when Node.js
  manager is skipped (ensures shell env files exist in all code paths)
- Add build.rs with /DEPENDENTLOADFLAG:0x800 linker flag for DLL
  hijacking prevention at load time (complements runtime mitigation)
- Add test-vp-setup-exe CI job to test-standalone-install.yml testing
  silent installation from cmd, pwsh, and bash on Windows
The junction crate was moved to vite_setup when extracting the shared
installation logic. cargo-shear correctly flagged it as unused.
Replace the flat numbered list with a phased ASCII diagram grouped
into Resolve, Download & Verify, Install, Activate, and Configure
phases. Add a function-to-crate mapping table and document the
failure recovery boundary (pre/post Activate phase). Annotate
conditional steps (save_previous_version only on upgrade,
modify PATH gated by --no-modify-path).
@fengmk2 fengmk2 force-pushed the windows-installer branch from 1b3a6a3 to 4dc36b5 Compare April 4, 2026 12:59
fengmk2 added 3 commits April 4, 2026 21:03
- Update status from "Draft" to "Implemented"
- Fix Code Sharing table: all install functions are in vite_setup::install,
  not separate submodules
- Fix Dependency Graph: remove junction (indirect via vite_setup), add
  actual deps (vite_path, owo-colors)
- Fix Customization submenu to match code (numbered items, no install dir)
- Replace winreg code sample with raw FFI description (matches implementation)
- Replace windows_sys DLL sample with raw FFI (matches implementation)
- Remove winreg from Binary Size Budget, add raw FFI note
- Fix Alternatives #4: raw FFI, not winreg
- Fix CI snippets: rename vite-init to vp-setup, update test workflow
  to match actual test-vp-setup-exe job
- Mark Implementation Phases 1-3 as done, Phase 4 as future
…ccess

The zero-dependency pattern made sense for vite_trampoline (copied 5-10
times as shim files) but not for a single downloadable installer where
readability matters more. Switch from 225 lines of unsafe raw Win32 FFI
to ~80 lines of safe Rust using the winreg crate (~50-100 KB after LTO).

WM_SETTINGCHANGE broadcast still uses a single raw FFI call since
winreg doesn't wrap SendMessageTimeoutW.
- Extract VP_BINARY_NAME constant to avoid duplicated cfg!(windows)
  binary name literals
- Remove redundant exists() check in replace_windows_exe — just attempt
  the rename unconditionally (rename failure is already ignored)
- Trim verbose WHAT-comments to concise single-line doc comments
fn main() {
// On Windows, set DEPENDENTLOADFLAG to only search system32 for DLLs at load time.
// This prevents DLL hijacking when the installer is downloaded to a folder
// containing malicious DLLs (e.g. Downloads). Matches rustup's approach.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fengmk2 added 8 commits April 4, 2026 22:15
Fix all high/P1/P2 issues from both adversarial and standard reviews:

1. Node.js manager auto-detect: port the full auto-detect logic from
   install.ps1/install.sh instead of unconditionally enabling shims.
   Checks VP_NODE_MANAGER env, existing shims, CI/devcontainer, system
   node availability — and prompts interactively when system node exists
   (matching install.ps1 behavior). Silent mode (-y) skips the prompt
   and does not enable shims when system node is present.

2. Same-version repair: when the target version is already installed,
   skip download/extract/deps but still run all post-activation setup
   (shims, Node.js manager, PATH, env files). This allows rerunning
   the installer to repair a broken installation.

3. Rollback protection: include the previous version in protected_versions
   during cleanup, matching the vp upgrade implementation. Prevents
   cleanup from deleting the rollback target.

4. Post-activation best-effort: setup_bin_shims, refresh_shims, and
   modify_path are now wrapped in if-let-Err with warnings instead of
   propagating errors. After activation (current junction swap), the
   core install has succeeded — configuration failures should not cause
   exit code 1.
- Move same-version check before platform package HTTP request: use
  resolve_version_string (1 HTTP call) first, then skip
  resolve_platform_package (2nd HTTP call) when version matches.
  Saves 1 HTTP request for tag matches, both for exact version matches.
- Fix else { if let → else if let (clippy collapsible_else_if)
- Consolidate VP_NODE_MANAGER handling: both "yes" and "no" now checked
  in should_enable_node_manager instead of split across cli.rs and main.rs
- Make create_env_files return Result and report via print_warn,
  consistent with other best-effort post-activation steps
Move all user prompts to the menu phase — do_install is now prompt-free.

The auto_detect_node_manager() function is pure logic (no I/O) that
resolves the Node.js manager default based on: VP_NODE_MANAGER env,
existing shims, CI/devcontainer, system node presence. The result is
stored in opts.no_node_manager before showing the interactive menu,
so the user sees the resolved value ("enabled"/"disabled") and can
toggle it in the customize submenu before installation begins.

When system node is present and no other signal overrides, the default
is "disabled" — the user can enable it via the customize menu.
In silent mode (-y), this means shims are not created unless explicitly
requested via VP_NODE_MANAGER=yes or auto-detected (CI, no system node).
…tive mode

When system node is present:
- Interactive mode: default to enabled (matching install.ps1's Y/n
  prompt where Enter = yes). User can disable via customize menu.
- Silent mode (-y): default to disabled (don't silently take over).

This matches install.ps1 behavior where most interactive users who
press Enter get node management enabled by default.
Replace dynamic matrix.shell in shell: field with explicit shell values
per step. The matrix.shell expression was not recognized by the GitHub
Actions YAML parser when used in the shell: context. Use a single job
that verifies installation from pwsh, cmd, and bash sequentially.
- Update interactive menu examples to show "enabled"/"disabled" instead
  of "auto-detect" (value is now pre-computed)
- Add Node.js Manager Auto-Detection section with priority table
  documenting the full auto-detect logic matching install.ps1/install.sh
- Restructure Installation Flow diagram: local version check before HTTP,
  split resolve_version into resolve_version_string + resolve_platform_package,
  same-version repair path skips to CONFIGURE, cleanup moved to ACTIVATE
- Update Existing Installation Handling: same version now repairs instead
  of exiting early
- Document best-effort post-activation behavior and failure recovery
- Update function mapping table with split registry functions
- Update Test Workflow snippet to match actual single-job structure
- Update Phase 2 description (winreg, pre-computed node manager, repair)
This function follows the same pattern as refresh_shims (spawn vp with
different args) and belongs in the shared library alongside it.
@fengmk2 fengmk2 force-pushed the windows-installer branch from 672909f to 816d7f1 Compare April 4, 2026 15:07
fengmk2 added 2 commits April 4, 2026 23:17
… builds

Use setup-dev-drive with ReFS (matching ci.yml) to speed up cargo build.
Windows Defender skips ReFS dev drives, which significantly reduces
build times on GitHub Actions Windows runners.

- name: Install via vp-setup.exe (silent)
shell: pwsh
run: ${{ format('{0}/target/release/vp-setup.exe', env.DEV_DRIVE) }}

- **Binary name**: `vp-setup.exe`
- **Uninstall**: Rely on `vp implode` — no `--uninstall` flag in the installer
- **Minimum Windows version**: Windows 10 1809+ (same as Rust's MSVC target)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version information is not clear enough; at minimum, you need to specify when the version was released.


### Phase 2: Direct Download URL

Host at `https://vite.plus/vp-setup.exe` with architecture auto-detection (default x64).
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should use void worker to handle the architecture detect logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants