Ubuntu 22.04.3下Rider 2023搭配dotnet-8.0无法运行项目求助
问题:升级.NET 8后Rider无法运行项目
之前安装了.NET SDK 7.0,所有功能运行正常。昨日通过命令sudo apt remove 'dotnet*' 'aspnet*' 'netstandard*'卸载了系统中现有.NET包,再从微软软件仓库安装了.NET SDK 8.0,现在Rider无法运行项目。
系统信息
Ubuntu 22.04.3 LTS
dotnet --info输出
.NET SDK: Version: 8.0.100 Commit: 57efcf1350 Workload version: 8.0.100-manifests.6c33ef20 Runtime Environment: OS Name: ubuntu OS Version: 22.04 OS Platform: Linux RID: linux-x64 Base Path: /usr/share/dotnet/sdk/8.0.100/ .NET workloads installed: Workload version: 8.0.100-manifests.6c33ef20 There are no installed workloads to display. Host: Version: 8.0.0 Architecture: x64 Commit: 5535e31a71 .NET SDKs installed: 8.0.100 [/usr/share/dotnet/sdk] .NET runtimes installed: Microsoft.AspNetCore.App 8.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 8.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App] Other architectures found: None Environment variables: Not set global.json file: Not found Learn more: https://aka.ms/dotnet/info Download .NET: https://aka.ms/dotnet/download
工具集与构建配置

Rider错误信息
/.../Project/src/Xxx.GraphQl/bin/Debug/net8.0/DataGateway.GraphQl You must install .NET to run this application. App: /.../Project/src/Xxx.GraphQl/bin/Debug/net8.0/DataGateway.GraphQl Architecture: x64 App host version: 8.0.0 .NET location: Not found Learn more: https://aka.ms/dotnet/app-launch-failed Download the .NET runtime: https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=linux-x64&os=ubuntu.22.04&apphost_version=8.0.0 Process finished with exit code 131.
解决思路
- 检查Rider的.NET SDK配置:打开Rider设置(File > Settings),进入Build, Execution, Deployment > Toolset and Build,确认已选中已安装的.NET 8.0 SDK;同时右键项目选择Properties > Application,确认目标框架设置为net8.0。
- 验证命令行运行:在项目根目录执行
dotnet run --project src/Xxx.GraphQl,若命令行可正常运行,说明问题出在Rider配置;若同样报错,继续排查安装问题。 - 配置环境变量:检查
DOTNET_ROOT是否指向/usr/share/dotnet,终端执行echo $DOTNET_ROOT查看。若未设置,将export DOTNET_ROOT=/usr/share/dotnet添加到~/.bashrc或~/.zshrc,然后执行source ~/.bashrc(或对应配置文件)生效。 - 重新安装.NET SDK:执行
sudo apt-get install --reinstall dotnet-sdk-8.0,确保SDK组件完整。 - 清理项目缓存:删除项目的
bin和obj目录,在Rider中执行Clean Solution后再Rebuild Solution。 - 升级Rider版本:确保Rider版本为2023.2及以上(该版本开始支持.NET 8),若版本过低,升级Rider。
内容的提问来源于stack exchange,提问作者Andriy
相关产品推荐
相关产品推荐

