diff --git a/bucket/vscode.json b/bucket/vscode.json index 26867ae7ad8794..94bc8e3e297eba 100644 --- a/bucket/vscode.json +++ b/bucket/vscode.json @@ -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\" ", "}"