Install and run C# (dotnet) program environment under linux
If you want to run a C# program under linux, you need to install dotnet-sdk-6.0 (the version number here depends on your own needs)
If the data source of yum is not domestic, it is recommended to change the data source of yum for speed reasons: yum change source operation
First check the system version number:
hostnamectl
result:
Static hostname: localhost.localdomain
Icon name: computer-desktop
Chassis: desktop
Machine ID: aecafa7c476644a6b64b462691829111
Boot ID: c2f3b9ea3dac4c5e93fcc4991752d111
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-1160.71.1.el7.x86_64
Architecture: x86-64
First add the C# data source that configures the corresponding centos version (7 here)
You can click the link to find the system and version you need https://packages.microsoft.com/config/
sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
Find the dotnet-sdk version that needs to be installed
yum search dotnet-sdk
result:
[root@localhost ~]# yum search dotnet-sdk
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.ustc.edu.cn
* extras: mirrors.ustc.edu.cn
* updates: mirrors.ustc.edu.cn
============= N/S matched: dotnet-sdk ===================
dotnet-sdk-2.1.x86_64 : Microsoft .NET Core SDK 2.1.818 2.1.818
dotnet-sdk-2.2.x86_64 : Microsoft .NET Core SDK 2.2.402 2.2.402
dotnet-sdk-3.0.x86_64 : Microsoft .NET Core SDK 3.0.103 3.0.103
dotnet-sdk-3.1.x86_64 : Microsoft .NET Core SDK 3.1.426 3.1.426
dotnet-sdk-5.0.x86_64 : Microsoft .NET SDK 5.0.408 5.0.408
dotnet-sdk-6.0.x86_64 : Microsoft .NET SDK 6.0.410 6.0.410
dotnet-sdk-7.0.x86_64 : Microsoft .NET SDK 7.0.304 7.0.304
Yum installs the C# dependency package (6.0 here)
sudo yum install dotnet-sdk-6.0
#查看是否安装成功
dotnet --list-sdks
#查看依赖包信息查看
dotnet --info
After the installation is complete, the program is packaged, and the C# program can be run directly on liunx.
How to package windows, please see the next article: [C# compile linux executable program] C# compile linux executable program under visual studio 2022