赞
踩
前言
我们需要将.NET8编写的console控制台程序,部署在Ubuntu服务器上运行。
安装.NET运行时
1.增加微软包安装源
- wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
- sudo dpkg -i packages-microsoft-prod.deb
- rm packages-microsoft-prod.deb
2.安装.NET8运行时
sudo apt-get update && sudo apt-get install -y aspnetcore-runtime-8.0
安装SDK(如果需要编译)
sudo apt-get update && sudo apt-get install -y dotnet-sdk-8.0
3.验证是否安装成功
dotnet --info
- root@ubuntu01:/# dotnet --info
-
- Host:
- Version: 8.0.5
- Architecture: x64
- Commit: 087e15321b
- RID: linux-x64
-
- .NET SDKs installed:
- No SDKs were found.
-
- .NET runtimes installed:
- Microsoft.AspNetCore.App 8.0.5 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
- Microsoft.NETCore.App 8.0.5 [/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
- root@ubuntu01:/#
运行程序
1.将发布后文件夹上传到linux服务器
2.添加执行权限
chmod +x -R /file/helloworld/
3.运行DotNet程序
dotnet helloworld.dll
- # 增加微软包安装源
-
- wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
- sudo dpkg -i packages-microsoft-prod.deb
- rm packages-microsoft-prod.deb
-
-
- # 安装SDK(如果需要编译)
-
- sudo apt-get update && sudo apt-get install -y dotnet-sdk-8.0
-
-
- # 安装运行时
-
- sudo apt-get update && sudo apt-get install -y aspnetcore-runtime-8.0
-
- # 验证是否安装成功
-
- dotnet --info
-
- # 上传发布文件到linux服务器
-
-
- # 添加执行权限
-
- chmod +x -R /file/helloworld/
-
- # 运行DotNet程序
-
- dotnet helloworld.dll
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。