From b7e7357c34c42b7124150daa669d8c987346ecf5 Mon Sep 17 00:00:00 2001 From: Timabliss <1173814187@qq.com> Date: Thu, 12 Feb 2026 21:32:22 +0800 Subject: [PATCH] vscode: Parse 'bin/code' for version hash & auto-clean registry Major refactor of the `post_install` logic to improve robustness and registry hygiene: 1. Deterministic Version Detection (Source of Truth): Instead of unreliable directory sniffing, we now parse the official `bin/code` shell script to extract the `VERSIONFOLDER` variable. This is the upstream source of truth for the version hash. 2. Dynamic Registry Template Injection: - Context Menus & Associations: Injected with the resolved hash path (e.g., `$dir\`). - GitHub Integration: Injected with the root path (`$dir`), as per standard behavior. - Handled via variable replacement in `.reg` templates during runtime. 3. Update-Triggered Registry Cleanup: Implemented a "Clean Slate" policy. During an update (detected by the presence of older version directories matching `^[0-9.]+$`), the script automatically runs uninstall routines for the previous registration. This prevents registry pollution and ensures that HKCU keys strictly correspond to the current installation. --- bucket/vscode.json | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/bucket/vscode.json b/bucket/vscode.json index 8629913edeb1c1..6bc381324b8524 100644 --- a/bucket/vscode.json +++ b/bucket/vscode.json @@ -1,5 +1,5 @@ { - "version": "1.109.2", + "version": "1.109.3", "description": "Lightweight but powerful source code editor", "homepage": "https://code.visualstudio.com/", "license": { @@ -16,12 +16,12 @@ ], "architecture": { "64bit": { - "url": "https://update.code.visualstudio.com/1.109.2/win32-x64-archive/stable#/dl.7z", - "hash": "cba3d45e0b365b26dfb401249e086bf14ae8ee29bc94f47a64c270cc0f3079cb" + "url": "https://update.code.visualstudio.com/1.109.3/win32-x64-archive/stable#/dl.7z", + "hash": "c361df07f756f3b53e9286cbed02c89533813687a4406fd65e93af3daa73f388" }, "arm64": { - "url": "https://update.code.visualstudio.com/1.109.2/win32-arm64-archive/stable#/dl.7z", - "hash": "d7cdcf7fe0ec475ebd67ca9d390d6d84915e9d372c0c222f2c5ae0ff58270962" + "url": "https://update.code.visualstudio.com/1.109.3/win32-arm64-archive/stable#/dl.7z", + "hash": "fb90cd4e94a8ee34fb2413a324d1a5544b54af4036e40e865e00d9d6e9a91486" } }, "env_add_path": "bin", @@ -34,10 +34,17 @@ "post_install": [ "$dirpath = \"$dir\".Replace('\\', '\\\\')", "$exepath = \"$dir\\Code.exe\".Replace('\\', '\\\\')", + "$targetpath = $dirpath", + "if (Test-Path \"$dir\\bin\\code\") {", + " if ((Get-Content \"$dir\\bin\\code\" -Raw) -match 'VERSIONFOLDER=\"([^\"]+)\"') {", + " $targetpath = \"$dir\\$($matches[1])\".Replace('\\', '\\\\')", + " }", + "}", "'install-associations', 'uninstall-associations', 'install-context', 'uninstall-context', 'install-github-integration', 'uninstall-github-integration' | ForEach-Object {", " if (Test-Path \"$bucketsdir\\extras\\scripts\\vscode\\$_.reg\") {", " $content = Get-Content \"$bucketsdir\\extras\\scripts\\vscode\\$_.reg\"", - " $content = $content.Replace('$codedir', $dirpath)", + " if ($_ -match 'github') {$tmppath = $dirpath} else {$tmppath = $targetpath}", + " $content = $content.Replace('$codedir', $tmppath)", " $content = $content.Replace('$code', $exepath)", " if ($global) {", " $content = $content.Replace('HKEY_CURRENT_USER', 'HKEY_LOCAL_MACHINE')", @@ -57,12 +64,23 @@ "if ((Test-Path \"$extensions_file\")) {", " info 'Adjusting path in extensions file...'", " (Get-Content \"$extensions_file\") -replace '(?<=vscode(/|\\\\\\\\)).*?(?=(/|\\\\\\\\)data(/|\\\\\\\\)extensions)', $version | Set-Content \"$extensions_file\"", + "}", + "$appRoot = Split-Path $dir -Parent", + "$otherVersions = @(Get-ChildItem $appRoot -Directory | Where-Object { $_.FullName -ne $dir -and $_.Name -ne 'current' -and ($_.Name -match '^[0-9.]+$') })", + "if ($otherVersions.Count -gt 0) {", + " 'uninstall-associations', 'uninstall-context', 'uninstall-github-integration' | ForEach-Object {", + " $regFile = \"$dir\\$_.reg\"", + " if (Test-Path $regFile) {", + " regedit /s \"$regFile\"", + " }", + " }", "}" ], "uninstaller": { "script": [ "if ($cmd -eq 'uninstall')", "{", + " reg import \"$dir\\uninstall-associations.reg\" ", " reg import \"$dir\\uninstall-context.reg\" ", " reg import \"$dir\\uninstall-github-integration.reg\" ", "}"