为 VSCode 安装 C# 扩展时出错

Error on installing C# Extension for VSCode

我正在尝试安装 VSCode 扩展程序 C# for Visual Studio Code (powered by OmniSharp) 但没有成功。在 VSCode 的 Output 选项卡中,我收到以下错误:

Updating C# dependencies...
Platform: win32, x86_64

Downloading package 'OmniSharp for Windows (.NET 4.6 / x64)'    Retrying from 'https://omnisharpdownload.blob.core.windows.net/ext/omnisharp-win-x64-1.26.3.zip' Downloading package '.NET Core Debugger (Windows / x64)'   Retrying from 'https://vsdebugger.blob.core.windows.net/coreclr-debug-1-13-0/coreclr-debug-win7-x64.zip' 
Installing package 'OmniSharp for Windows (.NET 4.6 / x64)'
Failed at stage: installPackages
Error: end of central directory record signature not found

Finished

根据我在omnisharp-vscodeGitHub页面上找到的相关问题:

并且知道我使用的是企业代理,因此我必须像 vscode 用户设置中那样在 vscode 中设置 http.proxy 设置:

{
    "http.proxy": "<my-proxy-uri>" // e.g. http://1.2.3.4:55,
}

检查 omnisharp 下载失败的原因总是更好。

您可以通过将选项卡切换到 Output 然后将下拉菜单更改为 OmniSharp Log

来进行检查

对我来说,每次的错误都不一样,大部分时间是公司代理,下一次是不兼容的 c# 扩展,正在下载 omnisharp。

出现此问题的主要原因是 VS 代码正在尝试自动下载和安装文件,但被公司代理阻止了。

要解决此问题,请单击错误的 link、

手动下载文件

关闭Vs Code,根据omnisharp log手动解压下载的zip并粘贴到位置

现在你一定可以开始了。