今天在服务器上更新了dotnet后想查看下已安装的所有版本
dotnet --info
-bash: /usr/bin/dotnet: 没有那个文件或目录
瞬间懵逼了,经过查阅资料后发现,早期版本的dotnet安装的是/usr/local/bin/
下,因此环境变量也就在该目录,后期的版本则安装到了/usr/share/
下,于是尝试了下
/usr/share/dotnet/dotnet --info
.NET SDK (反映任何 global.json):
Version: 5.0.403
Commit: bf9d168ac2
运行时环境:
OS Name: centos
OS Version: 7
OS Platform: Linux
RID: centos.7-x64
Base Path: /usr/share/dotnet/sdk/5.0.403/
Host (useful for support):
Version: 5.0.12
Commit: 7211aa01b3
.NET SDKs installed:
3.1.415 [/usr/share/dotnet/sdk]
5.0.403 [/usr/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.2.8 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.8 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.8 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.12 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.8 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.8 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.12 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
问题找到了,但这是线上环境,如果改环境变量的话,可能会导致直接使用早期版本的绝对路径的服务炸锅,因此我选择了软连接的方式
sudo ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet
此时再运行dotnet
便没有错误了