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

Ubuntu系统下.NET 7.0安装失败求助:创建项目终端超时

解决Ubuntu下.NET 7.0安装失败及项目创建超时问题

问题概述

安装.NET 7.0时反复触发如下错误:

An error occurred while installing .NET (7.0): .NET Acquisition Failed: Installation failed: Error: Command failed: "/home/speed/.vscode/extensions/ms-dotnettools.vscode-dotnet-runtime-1.6.0/dist/install scripts/dotnet-install.sh" -InstallDir "/home/speed/.config/Code/User/globalStorage/ms-dotnettools.vscode-dotnet-runtime/.dotnet/7.0.8" -Version 7.0.8 -Runtime dotnet

执行「创建.NET项目」操作时,终端加载后超时,已尝试卸载重装SDK、手动安装依赖、调整$PATH等方法均无效。

针对性解决方案

1. 修复安装脚本权限

VS Code扩展的dotnet-install.sh可能因权限不足无法执行,运行以下命令赋予执行权限:

chmod +x "/home/speed/.vscode/extensions/ms-dotnettools.vscode-dotnet-runtime-1.6.0/dist/install scripts/dotnet-install.sh"

之后重新触发VS Code的.NET安装流程。

2. 绕过扩展,手动部署全局.NET 7.0 Runtime

  1. 卸载VS Code中的ms-dotnettools.vscode-dotnet-runtime扩展
  2. 手动下载并安装.NET 7.0 Runtime:
    wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
    chmod +x dotnet-install.sh
    ./dotnet-install.sh -c 7.0 -Runtime dotnet -InstallDir /usr/local/dotnet
    
  3. 将全局.NET路径加入系统环境变量:
    echo 'export PATH="$PATH:/usr/local/dotnet"' >> ~/.bashrc
    source ~/.bashrc
    
  4. 验证安装结果:
    dotnet --version
    
  5. 重新安装VS Code的.NET扩展,扩展会自动识别全局安装的.NET环境,无需单独下载。

3. 补全系统依赖库

Ubuntu运行.NET需要特定系统库,执行以下命令安装全部必需依赖:

sudo apt-get update && sudo apt-get install -y libc6 libgcc1 libgssapi-krb5-2 libssl3 libstdc++6 zlib1g

若为Ubuntu 22.04及以上版本,额外安装:

sudo apt-get install -y libicu70

4. 清理VS Code扩展缓存

删除扩展的.NET缓存目录后重启VS Code,重新触发安装:

rm -rf "/home/speed/.config/Code/User/globalStorage/ms-dotnettools.vscode-dotnet-runtime/.dotnet"

验证方法

执行dotnet new console手动创建项目,若命令可正常生成项目,则VS Code的项目创建功能可恢复正常。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.17 10:17:33