You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CICD中安装多VS Code扩展及远程测试问题排查

VS Code远程测试中Remote-SSH扩展安装失败问题

问题背景

我在单元测试启动脚本中,通过CLI选项安装CI/CD生成的自定义VSIX扩展,同时尝试安装ms-vscode-remote.remote-ssh扩展,以实现远程工作区的测试运行。

测试脚本

import * as path from 'path';
import * as fs from 'fs';

import { runTests } from '@vscode/test-electron';

async function main() {
    try {
        // The folder containing the Extension Manifest package.json
        // Passed to `--extensionDevelopmentPath`
        const extensionDevelopmentPath = path.resolve(__dirname, '../../');

        // The path to the extension test runner script
        // Passed to --extensionTestsPath
        const extensionTestsPath = path.resolve(__dirname, './suite/index');

        const vsixName = fs.readdirSync(extensionDevelopmentPath)
            .filter(p => path.extname(p) === ".vsix")
            .sort((a, b) => a < b ? 1 : a > b ? -1 : 0)[0];

        const launchArgsLocal = [
            path.resolve(__dirname, '../../src/test/test-docs'),
            "--install-extension",
            vsixName,
            "--install-extension",
            "ms-vscode-remote.remote-ssh"
        ];
        const SSH_HOST = process.argv[2];
        const SSH_WORKSPACE = process.argv[3];
        const launchArgsRemote = [
            "--folder-uri",
            `vscode-remote://ssh-remote+testuser@${SSH_HOST}${SSH_WORKSPACE}`
        ];

        // Download VS Code, unzip it and run the integration test
        await runTests({ extensionDevelopmentPath, extensionTestsPath, launchArgs: launchArgsLocal });
        await runTests({ extensionDevelopmentPath, extensionTestsPath, launchArgs: launchArgsRemote });
    } catch (err) {
        console.error(err);
        console.error('Failed to run tests');
        process.exit(1);
    }
}

main();

问题现象

  • runTests会自动下载并安装VS Code,本地文件系统测试全部通过,证明自定义VSIX扩展已成功安装
  • ms-vscode-remote.remote-ssh扩展未安装成功,触发报错:Cannot get canonical URI because no extension is installed to resolve ssh-remote,导致远程测试因无法打开工作区失败
  • 怀疑问题由多次使用--install-extension参数导致

需求与已尝试方案

需要平台无关的解决方案,已尝试以下两种方式但均未解决:

  1. 在GitHub Action中预安装VS Code最新版及所需扩展,但测试框架未复用现有VS Code安装
  2. 通过扩展依赖的方式安装remote-ssh,但出现远程主机使用市场版本而非待测试版本的问题

内容的提问来源于stack exchange,提问作者Peter Wone

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 22:06:33