Mono 项目由微软赞助。它是 Microsoft .NET Framework 的开源跨平台实现。 Mono 支持大多数具有 32 位和 64 位架构的现代操作系统。本教程帮助您逐步在 Debian 10 和 Debian 9 系统上安装 Mono。
有用的教程:
-
如何在 Debian 上安装 Visual Studio Code
先决条件
使用 sudo 特权帐户通过 SSH 或 Shell 访问 Debian 系统。
在 Debian 上安装 Mono
首先,在 Debian 系统上安装一些必需的软件包并导入 GPG 密钥。
sudo apt install gnupg ca-certificates
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys D3D831EF
现在,在您的系统上添加官方网站提供的 Apt 存储库。使用以下命令之一将 Mono 存储库添加到基于 Ubuntu 版本的系统。
### Debian 10 (Buster)
echo "deb https://download.mono-project.com/repo/debian stable-buster main" | sudo \
tee /etc/apt/sources.list.d/mono-stable.list
### Debian 9 (Xenial)
echo "deb https://download.mono-project.com/repo/debian stable-xenial main" | sudo \
tee /etc/apt/sources.list.d/mono-stable.list
添加存储库后。更新 apt 缓存并在 Ubuntu 系统上安装 Mono 软件包。
sudo apt update
sudo apt install mono-complete mono-devel
The 单一开发package用于编译代码。这单一完整的软件包用于安装系统上的所有内容。
查找单声道版本
系统上的安装完成后。让我们使用以下命令检查已安装的 Mono 版本。
mono --version
Output:
Mono JIT compiler version 6.8.0.105 (tarball Tue Feb 4 21:20:20 UTC 2020)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
Interpreter: yes
LLVM: yes(610)
Suspend: hybrid
GC: sgen (concurrent by default)
使用 Mono 运行 C# 示例
因为你已经在 Ubuntu 系统上安装了 Mono。创建一个示例 C# 程序以与 Mono 一起运行。创建 Welcome.cs 文件并在您喜欢的文本编辑器中进行编辑。
vim Welcome.cs
将以下值添加到文件中。
|
using System;
public class Welcome
{
public static void Main(string[] args)
{
Console.写行 (“欢迎来到 TecAdmin.net”);
}
}
|
保存文件并关闭它。然后使用以下命令使用 C# 编译器编译 C# 程序。
csc Welcome.cs
编译成功后,会在本地目录下生成一个与script同名的exe文件。在这种情况下,我的本地目录中会生成一个 Welcome.exe 文件。
然后,设置新创建的可执行文件的执行权限。之后按以下命令运行程序。
chmod +x Welcome.exe
./Welcome.exe
查看屏幕上的结果:
全部完成后,您已经在 Debian 系统上成功安装了 Mono。接下来您可能需要安装 Visual Studio 代码在 Debian Linux 系统上。