.net 在 Ubuntu/Debian 中安装 Mono 3.x

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13365158/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 16:42:29  来源:igfitidea点击:

Installing Mono 3.x in Ubuntu/Debian

.netmono

提问by oasten

I've recently read that Mono 3.0 has been released with a C# 5 compiler and support for MVC 4 here:

我最近读到 Mono 3.0 已经发布,带有 C# 5 编译器并支持 MVC 4:

http://www.mono-project.com/Release_Notes_Mono_3.0

http://www.mono-project.com/Release_Notes_Mono_3.0

and

http://tirania.org/blog/archive/2012/Oct-22.html

http://tirania.org/blog/archive/2012/Oct-22.html

For the life of me I cannot work out where to get it from as a package for Linux or even Windows.

对于我的生活,我无法弄清楚从哪里获取它作为 Linux 甚至 Windows 的包。

This page seems to suggest it's still in Beta:

此页面似乎表明它仍处于测试阶段:

http://www.go-mono.com/mono-downloads/download.html

http://www.go-mono.com/mono-downloads/download.html

I've tried doing a apt-get install mono-completeon Ubuntu 12.10 but it's installed 2.10.8.1.

我试过apt-get install mono-complete在 Ubuntu 12.10 上做一个,但它安装了 2.10.8.1。

I've tried installing MonoDevelop 3 on my Windows machine and that's only presented me with MVC 3 projects and appears to be using the .NET framework.

我已经尝试在我的 Windows 机器上安装 MonoDevelop 3,但它只向我展示了 MVC 3 项目并且似乎使用了 .NET 框架。

I'm entirely new to Mono and I've Googled everything possible to try and see how this works but am baffled. I'd love to get this working on Linux if possible and try some stuff out.

我对 Mono 完全陌生,我已经在谷歌上搜索了所有可能的东西来尝试看看它是如何工作的,但我很困惑。如果可能的话,我很想让它在 Linux 上运行并尝试一些东西。

Can someone shed some light on this or do I need to be looking at building this from source?

有人可以对此有所了解吗,或者我是否需要从源头开始构建它?

采纳答案by knocte

Mono 3.x is too bleeding edge for Ubuntu 12.10. Grab preview packages from directhex's PPA this way (this will install 3.2.1):

Mono 3.x 对于 Ubuntu 12.10 来说太前沿了。以这种方式从 directhex 的 PPA 获取预览包(这将安装 3.2.1):

sudo add-apt-repository ppa:directhex/monoxide

(If you use Ubuntu saucy 13.10, after adding the repository you need to edit the file /etc/apt/sources.list.d/directhex-monoxide-saucy.listand replace the word saucywith raring)

(如果你使用Ubuntu 13.10鲁莽的,添加库后,你需要编辑的文件/etc/apt/sources.list.d/directhex-monoxide-saucy.list,并替换单词俏皮铆足了劲

Then, after that:

然后,在那之后:

sudo apt-get update && sudo apt-get dist-upgrade

This will also get you MonoDevelop 4.x if you had monodevelop installed before.

如果您之前安装了 monodevelop,这也将为您提供 MonoDevelop 4.x。

NOTE: directhex is not some random guy that created a PPA, he's part of the Debian/Ubuntu maintainer team of all the Mono and Mono-based packages. So using this is the most official way to upgrade your infrastructure.

注意:directhex 不是创建 PPA 的随机人员,他是所有 Mono 和基于 Mono 的软件包的 Debian/Ubuntu 维护者团队的一员。因此,使用它是升级基础架构的最官方方式。



And for the debian users out there: mono 3.0.6 and MonoDevelop 4.0.x is already available in debian testing. So what I recommend to get this is:

对于 debian 用户:mono 3.0.6 和 MonoDevelop 4.0.x已经在 debian testing 中可用。所以我建议得到这个是:

  1. Install debian testing (currently named debian jessie).
  2. Uninstall mono by doing sudo apt-get purge mono-runtime(after doing this, resist the temptation to do an sudo apt-get autoremoveor you will break your system, something which I reported as a bug here).
  3. Modify /etc/apt/sources.list, locate the first line that mentions the mainsource, and rename the word jessieto sid.
  4. Do sudo apt-get update.
  5. Install monodevelop via sudo apt-get install monodevelop, which will pull mono as a dependency too.
  6. Revert what you did in step 3.
  7. Do step 4 again.
  1. 安装 debian testing(当前名为 debian jessie)。
  2. 通过这样做来卸载单声道sudo apt-get purge mono-runtime(在这样做之后,抵制这样做的诱惑,sudo apt-get autoremove否则你会破坏你的系统,我在这里报告了一个错误)。
  3. 修改/etc/apt/sources.list,找到提到main来源的第一行,并将单词重命名jessiesid
  4. sudo apt-get update
  5. 通过 安装 monodevelop sudo apt-get install monodevelop,这也会将 mono 作为依赖项。
  6. 还原您在第 3 步中所做的操作。
  7. 再次执行步骤 4。

This way you have a more or less modern distro (as opposed to debian stable), plus very very modern mono packages (the bleeding edge versions for Mono are normally pretty stable).

这样你就有了一个或多或少的现代发行版(与 debian stable 相对),加上非常现代的 mono 包(Mono 的前沿版本通常非常稳定)。

F# users: Mono 3.0.6 has a bug that prevents this language to work in this version, please use Mono 3.2.x instead.

F# 用户:Mono 3.0.6 有一个错误,无法在此版本中使用该语言,请改用 Mono 3.2.x。

回答by Dominique Goudreault

Here is the complete guide for installing mono 3.0.1

这是安装 mono 3.0.1 的完整指南

For Beginners who don't know how to get the new Mono 3.0.1 version on Ubuntu 12.04 (Because i'm a beginner and i've been working on this for 3 days before making it work)

对于不知道如何在 Ubuntu 12.04 上获取新的 Mono 3.0.1 版本的初学者(因为我是初学者,我已经为此工作了 3 天,然后才使它工作)

Getting root access to install and configure Mono 3.0.1

获得 root 访问权限以安装和配置 Mono 3.0.1

sudo -s
***type your root password***

Install vim editor

安装 vim 编辑器

apt-get install vim

Install apache2

安装apache2

apt-get install apache2

Install tools for compiling mono

安装编译mono的工具

apt-get install autoconf automake libtool g++ gettext libglib2.0-dev libpng12-dev libfontconfig1-dev
apt-get install mono-gmcs
apt-get install git

Install apache2-threaded-dev (needed for compiling mod_mono)*

安装 apache2-threaded-dev(编译 mod_mono 需要)*

apt-get install apache2-threaded-dev

We will return to apache2 configuration later

后面我们会回到apache2的配置

Making the structure we need for getting the source code

制作我们获取源代码所需的结构

cd /opt
mkdir mono-3.0

Move into that new folder before getting the source code

在获取源代码之前移动到那个新文件夹

cd /opt/mono-3.0

Getting the source code from GitHub

从 GitHub 获取源代码

git clone git://github.com/mono/mono.git
git clone git://github.com/mono/xsp.git
git clone git://github.com/mono/libgdiplus.git
git clone git://github.com/mono/mod_mono.git

Compile libgdiplus

编译 libgdiplus

cd /opt/mono-3.0/libgdiplus
./autogen.sh --prefix=/usr  (the prefix is very important for Ubuntu 12.04)
make
make install

Compile mono

编译单声道

cd /opt/mono-3.0/mono/
make clean
./autogen.sh --prefix=/usr  (the prefix is very important for Ubuntu 12.04)
make
make install

Compile xsp

编译 xsp

cd /opt/mono-3.0/xsp
./autogen.sh --prefix=/usr  (the prefix is very important for Ubuntu 12.04)
make
make install

Compile mod_mono

编译 mod_mono

cd /opt/mono-3.0/mod_mono
./autogen.sh --prefix=/usr  (the prefix is very important for Ubuntu 12.04)
make
make install

After the installation of mod_mono, the file mod_mono.conf*as been added to your apache2 folder(/etc/apache2)*

安装 mod_mono 后,文件 mod_mono.conf*已添加到您的 apache2 文件夹 (/etc/apache2)*

Configuring apache2

配置apache2

Configure the default site of apache ### (optional*)**

配置apache的默认站点###(可选*)**

vim /etc/apache2/sites-available/default
Modify the line "DocumentRoot /var/www" by "DocumentRoot /var/www/YourFolder" (YourFolder is the folder where you publishing your website!)

Configure the rights to YourFolder (optional*)**

配置对 YourFolder 的权限(可选*)**

cd /var/www/YourFolder
sudo chown -R root:www-data .
sudo chmod -R 774 .
sudo usermod -a -G www-data <yourusername>

Adding the mod_mono include in apache2.conf

在 apache2.conf 中添加 mod_mono 包含

vim /etc/apache2/apache2.conf
Add "Include /etc/apache2/mod_mono.conf" at the end of the file (without quotes!)

Adding the pointer to ASP .NET 4.0 in mod_mono.conf

在 mod_mono.conf 中添加指向 ASP .NET 4.0 的指针

vim /etc/apache2/mod_mono.conf
Add "MonoServerPath /usr/bin/mod-mono-server4" (without quotes!) under the "If Modules condition"

Restart the apache2 server/etc/init.d/apache2 restart

重启apache2服务器/etc/init.d/apache2 restart

回答by Rolf S

I've got installing mono 3.x from source down to a few steps on Ubuntu Raring:

我已经从源代码到 Ubuntu Raring 上的几个步骤安装了 mono 3.x:

1: Get the dependencies, all in one hit:

1:一键获取依赖:

sudo apt-get install build-essential autoconf automake \
bison flex gtk-sharp2-gapi boo gdb valac libfontconfig1-dev \
libcairo2-dev libpango1.0-dev libfreetype6-dev libexif-dev \
libtiff4-dev libgif-dev zlib1g-dev libatk1.0-dev libjpeg8-dev \
libjpeg-turbo8-dev libglib2.0-dev libgtk2.0-dev libglade2-dev \
libart-2.0-dev libgnomevfs2-dev libgnome-desktop-dev \
libgnome2-dev libgnomecanvas2-dev libgnomeui-dev libgnomeprint2.2-dev \
libgnomeprintui2.2-dev libpanel-applet-4-dev \
libnautilus-extension-dev librsvg2-dev libgtkhtml3.14-dev \
libgtksourceview2.0-dev libgtksourceview2.0-dev libvte-dev \
libwnck-dev libnspr4-dev libnss3-dev libwebkit-dev libvala-0.18-dev

2: Create a folder somewhere to hold the source:

2:在某处创建一个文件夹来保存源:

sudo mkdir /opt/mono-3

3: Clone into the folder with git

3:用git克隆到文件夹中

cd /opt/mono-3
sudo git clone git://github.com/mono/mono.git
cd  mono
sudo git checkout mono-3.0.12

4: Build & Install

4:构建和安装

sudo ./autogen.sh --prefix=/usr/local
sudo make
sudo make install

That's it!

就是这样!

To get the latest changes in System.Drawing.dll and System.Windows.Forms.dll you also need configure, build and install libgdiplus.

要获得 System.Drawing.dll 和 System.Windows.Forms.dll 中的最新更改,您还需要配置、构建和安装 libgdiplus。

 cd libgdiplus
 ./autogen.sh --prefix=/usr/local
 make
 make install

回答by Martin Baulig

apt-get installinstalls whichever version of Mono your distribution ships with, which seems to be 2.10.8.1. Your distribution may or may not have newer Mono packages, you may have to select some newer update channel in your distribution's package manager. Since you did not mention which Linux distribution (and which version of it) you're using, this is impossible to answer.

apt-get install安装您的发行版随附的 Mono 版本,似乎是 2.10.8.1。你的发行版可能有也可能没有更新的 Mono 包,你可能需要在你的发行版的包管理器中选择一些更新的更新渠道。由于您没有提到您使用的是哪个 Linux 发行版(以及它的哪个版本),因此无法回答。

apt-getsuggests that it's something Debian/Ubuntu-based, but there are many different versions. I'm a Mac person, so I just don't know.

apt-get表明它是基于 Debian/Ubuntu 的,但有许多不同的版本。我是 Mac 人,所以我不知道。

See http://www.mono-project.com/Compiling_Monofor instructions on how to compile from source.

有关如何从源代码编译的说明,请参见http://www.mono-project.com/Compiling_Mono

However, this question really belongs on superuser.com, you'll get better answers if you ask it there.

然而,这个问题确实属于 superuser.com,如果你在那里问它,你会得到更好的答案。

回答by Douglas

I didn't find this linked from anywhere, so it's probably unofficial, but you can get the Windows installer for Mono 3.0.10 from here:

我没有从任何地方找到这个链接,所以它可能是非官方的,但你可以从这里获得 Mono 3.0.10 的 Windows 安装程序:

http://download.mono-project.com/archive/3.0.10/windows-installer/mono-3.0.10-gtksharp-2.12.11-win32-0.exe

http://download.mono-project.com/archive/3.0.10/windows-installer/mono-3.0.10-gtksharp-2.12.11-win32-0.exe

Edit: To ensure that you're downloading the latest version, open http://download.mono-project.com/archive/, and check each of the version subdirectories (starting from the last and moving back) until you find one that contains a "windows-installer" subdirectory.

编辑:为确保您下载的是最新版本,请打开http://download.mono-project.com/archive/,并检查每个版本子目录(从最后一个开始并移回),直到找到一个包含一个“windows-installer”子目录。

回答by Johan

There is now a link to a Windows installer for Mono 3.0.1. Unfortunately it doesn't seem to install on Windows 7 64bit. You may have better luck.

现在有一个指向 Mono 3.0.1 的 Windows 安装程序的链接。不幸的是,它似乎无法安装在 64 位 Windows 7 上。你可能有更好的运气。

http://www.go-mono.com/mono-downloads/download.html

http://www.go-mono.com/mono-downloads/download.html

回答by TongZZZ

To complete Dominique Goudreault's great solution concerning " Denis The Menace's question in the comments, "Ubuntu 13.04 x86. It says /usr/bin/ld: testgdi.o: undefined reference to symbol 'g_print'"

要完成 Dominique Goudreault 关于“评论中的丹尼斯威胁的问题”的出色解决方案,Ubuntu 13.04 x86。它说 /usr/bin/ld: testgdi.o: undefined reference to symbol 'g_print'"

Please follow this simple trick which got it done for me.

请遵循这个为我完成的简单技巧。

http://www.sgvulcan.com/libgdiplus-2-10-9-build-fails-on-slacware-current64-2012-06/

http://www.sgvulcan.com/libgdiplus-2-10-9-build-fails-on-slacware-current64-2012-06/

I can't reply to the comment as I wished, so I have to put up another answer here, any suggestion for a better practice?

我无法按我的意愿回复评论,所以我必须在这里提出另一个答案,有什么更好的做法建议吗?

Update: Opps, I didn't notice David V has already pointed out the solution, gave all credit to him, my link says the same thing, but maybe provided a clearer path. :P

更新:Opps,我没有注意到 David V 已经指出了解决方案,全都归功于他,我的链接说的是同样的事情,但可能提供了更清晰的路径。:P