如何将 Mono GTK# 应用程序移植到其他平台?
我正在开发一个用 C# 编写的 Mono GTK# 桌面应用程序。我在 Mac (OS X v10.6.7) 上使用 MonoDevelop IDE (v2.4.2) 开发了我的应用程序。我的应用程序依赖 GTK# 库(显然)以及 Mono.WebServer2
库来运行本地 ASP.NET 服务器。
我已经在自己的 Mac 以及其他 Mac 上测试了我的应用程序。一切都很顺利。现在,我有兴趣将我的应用程序移植到其他平台(特别是 Windows 7 和 Ubuntu v11.04)。我一直在使用 mkbundle 命令,但在为 Mac OS X 之外的其他平台创建工作包方面没有任何运气。
由于我尝试了许多不同的解决方案但没有成功,所以我想听听 Mono 开发者的意见。您如何将您的应用程序移植到其他平台?
我已经使用 Visual Studio 开发 C# 很长时间了,但我对 Mono 开发环境还是个新手。因此,我非常感谢详细的解释。
非常感谢!
I am working on a Mono GTK# desktop app written in C#. I have developed my app using the MonoDevelop IDE (v2.4.2) on a Mac (OS X v10.6.7). My app depends on the GTK# library (obviously) as well as the Mono.WebServer2
library for running a local ASP.NET server.
I have tested my app on my own Mac as well as other Macs. Everything is working out great. Now, I am interested in porting my app to other platforms (specifically, Windows 7 and Ubuntu v11.04). I have been playing around with the mkbundle
command but I haven't had any luck in creating a working bundle for other platforms than Mac OS X.
Since I have tried a number of different solutions without success, I would like to hear from the Mono developers out there. What do you do to port your app to other platforms?
I have been developing C# using Visual Studio for a long time but I am new to the Mono development environment. Therefore, I would very much appreciate a detailed explanation.
Thank you very much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
听起来您实际上并不是在谈论移植,而是打包。 MonoDevelop 的“项目/创建包”功能可以创建简单的二进制包(zip 等)或源包(源代码加 makefile),但这些并不是分发给大多数最终用户的理想形式。需要一些额外的工作来为每个平台制作一个完善的安装程序。
mkbundle 将 Mono 运行时捆绑到您的应用程序中,因此它创建 100% 特定于平台的二进制文件。
对于 Mac,分发应用程序的常用方式是作为应用程序包。 MonoDevelop 不会为 GTK# 项目自动执行此操作,但我在博客上解释了如何执行此操作 。
对于 Ubuntu,您可以分发二进制文件的 zip 并要求您的用户安装 Mono、GTK# 和 xsp。如果您创建 .deb 包,则可以将这些依赖项嵌入到包清单中。 MonoDevelop没有任何用于创建deb/rpm linux包的工具,而且我自己对这个过程也不熟悉。
对于 Windows,您可以提供二进制文件的 zip 并要求您的用户安装 .NET 和 GTK# for .NET。您还可以创建一个 msi 安装程序并让它检查这些先决条件。
It doesn't really sound like you're talking about porting, rather packaging. MonoDevelop's "Project/Create Package" function can create simple binary packages (zips etc) or source packages (source plus makefiles) but these are not the ideal form to distribute to most end-users. Some additional work is required to make a polished installer for each platform.
mkbundle bundles the Mono runtime into your app, therefore it creates binaries that are 100% platform-specific.
For Mac, the usual way to distribute an app is as an app bundle. MonoDevelop doesn't automate this for GTK# projects, but I explained how to do it on my blog.
For Ubuntu, you can distribute a zip of binaries and require that your users install Mono, GTK# and xsp. If you create a .deb package, you can embed these dependencies into the package manifest. MonoDevelop doesn't have any tools for creating deb/rpm linux packages, and I'm not familiar with the process myself.
For Windows, you can provide a zip of binaries and require that your users install .NET and GTK# for .NET. You could also create a msi installer and have it check for these prerequisites.
看来你已经解决了 Mac 的打包问题了。
在 Ubuntu 上,您需要创建一个 .deb 软件包,其中包含您的应用程序并需要其他软件包作为依赖项(Mono、Mono.WebServer2、GTK#、GTK+ 等)。以下链接应该可以帮助您开始构建 Ubuntu 软件包:
https://wiki.ubuntu.com/UbuntuDevelopment
对于 Windows,如果您有 .NET 经验,您可能已经知道如何构建安装程序。我想说的是,您希望在 .NET 而不是 Mono 之上运行您的应用程序。这就是 Mono 团队自己做的事情(以 MonoDevelop 为例)。将 Mono 特定位(如 Mono.WebServer2)作为应用程序的一部分引入。
这里最大的问题是 GTK# 需要安装 GTK+ C 库。也许最简单的事情是检测 GTK# 是否作为安装程序的一部分安装,并要求用户安装 GTK#(如果需要)。无论如何,您都必须对所需的 .NET 版本进行相同的检测。您可以此处获取适用于 Windows 的 GTK#< /a>.
我没有很好的说明来执行此操作,但 Banshee 和 MonoDevelop 项目都做得很好。我会看一下这些项目,因为它们会准确地向您展示需要做什么。
https://github.com/mono/monodevelop
http://git.gnome.org/browse/banshee
编辑:
我最近才意识到 GTK# 的代码安装程序位于 GitHub 此处。
It sounds like you have already solved the problem of packaging for Mac.
On Ubuntu, you would want to create a .deb package that contains your app and requires other packages as dependencies (Mono, Mono.WebServer2, GTK#, GTK+, etc). The following link should get you started on building Ubuntu packages:
https://wiki.ubuntu.com/UbuntuDevelopment
For Windows, you probably already know how to build an installer if you have .NET experience. I would say that you would want to run your app on top of .NET instead of Mono. That is what the Mono team do themselves (for MonoDevelop as an example). Bring in the Mono specific bits like Mono.WebServer2 as part of your application.
Your biggest issue here will be that GTK# requires the GTK+ C libraries to be installed. Probably the easiest thing is to detect if GTK# is installed as part of the installer and ask your users to install GTK# if they need it. You are going to have to do the same detection for the .NET version you require anyway. You can get GTK# for Windows here.
I do not have great instructions for doing this but both the Banshee and MonoDevelop projects do it well. I would take a look at those projects as they will show you exactly what needs to be done.
https://github.com/mono/monodevelop
http://git.gnome.org/browse/banshee
EDIT:
I just recently realized that the code for the GTK# installer is on GitHub here.
Monodevelop 中也有可用的打包项目。你可以使用它们。
我怀疑 mkbundle 在 Linux 之外是否能正常工作。
另一种选择是在其他平台上打开您的项目(您可以使用 Monodevelop)并构建项目并使用其他一些应用程序来构建包。
There are is also packaging projects available in Monodevelop. you can use them.
I'm doubtful that mkbundle work well other than Linux.
Another option that open your project on other plateform (you can use Monodevelop) and build the project and use some other app to build package.
我最近刚刚创建了我自己用 MonoDevelop 编写的 .Net 项目的 deb 包。我从 MonoDevelop 创建了一个包含源代码和 makefile 的包(makefile 也由 MonoDevelop 生成),然后我使用了本指南>
http://www.webupd8.org /2010/01/how-to-create-deb-package-ubuntu-debian.html
创建 deb 包。依赖项是 mono-runtime 和 gtk-sharp2。
I just recently created deb package of my own .Net project written in MonoDevelop. From MonoDevelop I created a package with sources and makefiles (makefiles also generated by MonoDevelop) and then i used this guide>
http://www.webupd8.org/2010/01/how-to-create-deb-package-ubuntu-debian.html
to create deb package. Dependencies were mono-runtime and gtk-sharp2.