你能用 Xamarin 开发 Linux 应用程序吗?

是否可以使用相同代码库的 Xamarin 开发和构建 Linux 应用程序?

使用 Ubuntu 几年后,我现在的主要操作系统又是 Windows 了。但我也不是不可能换成麦克。

现在我对 Qt 有一点经验,但是对 Xamarin 没有经验。 有了 Qt,你可以开发 开始 Windows、 Linux、 Mac 和 为了 Windows、 Linux、 Mac、 iOS、 Android、 Windows Mobile... ... 他们对此非常清楚。

由于 Xamarin 现在是免费和开源的,而我在 Qt 方面还没有太多经验,我正在考虑尝试使用 Xamarin 进行跨平台开发,而不是使用 Qt。

不能在 Linux 上发布我的软件对我来说是个麻烦。能够在 Linux 上进行开发固然不错,但也是可选的。 但是在我所有的谷歌研究之后,我只能找到那些要求支持开发 开始 Linux 而不是 为了 Linux 的信息和人。

据我所知,这不应该是一个单独的单核细胞增多症的问题。但据我所知,Xamarin > Mono 和我不得到的一切在 Mono 我可以在 Xamarin。

我也不确定 Mono 在未来会得到多好的支持。在我看来,对微软而言,Xamarin 似乎比 Mono 本身更重要。

我不确定这是否可能,因为 Xamarin 是基于 Mono 的,但是微软有没有可能在某个时候决定不支持 Mono。NET 与 Xamarin 的兼容性,甚至完全取消单机版 Mono?

因此,我正在为所有我可以依赖的桌面和移动平台寻找一个单一的框架,在深入研究这些解决方案之前,我想知道 Xamarin 和/或 Mono 和/或 Xamarin + Mono 是否可以成为 Qt 的替代品。

106559 次浏览

No, Xamarin is not available for Linux. This was a conscious decision made by the Xamarin team several years ago:

Miguel de Icaza 2011-08-04 11:52:37 UTC

We face a QA problem here.

The problem with supporting Linux is that we would need to create a self-contained Mono packaging for all of the bits we ship since most Linux distributions are slightly off when it comes to Mono.

It also means that if we advertise "Linux" we would need to QA a dozen different combination due to different Linux distributions and different editions of each distribution.

Perhaps we would support just a single distribution and a single version, which is closer to what we have to do on Windows/Mac today.

To clarify, the Xamarin product range is not available on Linux (Xamarin Studio, Xamarin.iOS and Xamarin.Android) but MonoDevelop, the foundation of Xamarin Studio, and Mono, the cross-platform .NET runtime, definitely is.

You can build desktop software using MonoDevelop. The MonoDevelop site has plenty of instructions on getting started:

https://github.com/0xFireball/xamarin-android-linux

As matthewrdev said, Xamarin.Studio, Xamarin.iOS, and Xamarin.Android aren't "officially" supported; however, Xamarin.iOS uses virtual emulator anyway (and I don't think there will be a workaround for Xamarin.iOS to run on Linux), but for Xamarin Studio (MonoDevelop on Linux, or Jetbrain's Riders (how to run it on linux with no official support is also provided in the link) Can run on Linux as an alt for Xamarin.Studio, and that link I shared explains how to install Xamarin.Android on linux, so just for Xamarin.iOS you will need to migrate or dual boot or sth, I hope that helps! (I stopped using Xamarin my-self, however, this environment helps developing for Xamarin on linux!)

Seems that there is a chance of Xamarin Forms work on linux distros. In this reddit thread Miguel de Icaza says:

Some of our team members actually develop in Linux. The reason why we never released the Linux tools is because we were charging a lot of money and people would rightfully expect the software to be fully supported. We had enough keeping our Mac and Windows users happy, and adding an unknown number of Linux distributions sounded like a hard task. Now that we are open sourcing the SDKs and I no longer will feel bad if something does not work under a particular Linux configuration, I will be happy to release the Linux builds.

That is: the fact that Forms is an open source tool currently opens this possibility.

Just in case someone else comes accross this q/a: the situation has changed. With Xamarin.Forms 3.0, Gtk# is supported (as preview, at this moment). Therefore, full Linux GUI support is enabled.

So, Xamarin now covers:

The only thing left to wish for: JS/HTML5 Web App target platform, as part of Xamarin :)

Yes, as of mid-2018, it is possible to develop cross platform GUI applications that target windows/mac/linux/android/ios using the "Xamarin.Forms" library. Basically, you have one shared library project from cross platform code (UI and other cross platform stuff), and one project per platform for platform-specific code (Xamarin.Forms have one backend implementation for each platform. On Linux, this is using GTK).

However, with MonoDevelop you can only develop/build the cross-platform project and the linux-specific project of the application. You will still need to use Visual Studio or Rider to develop/build for the other platforms.

See the following answer: https://stackoverflow.com/a/53317021/298005

GTK is listed as one of supported platforms/backends for Xamarin.Forms which allows building apps for Linux (as well as macOS and Windows via same GTK project). Though it doesn't look like there was much of development since 2018/2019 and Xamarin.Forms 3.0. Tried running 2 apps with basic UI and compared GTK backedn on Windows/macOS (comparing to WPF and Xamarin.mac back-ends ) and found GTK not worth pursuing (basic scenarios failing).

You can track GTK progress at https://github.com/jsuarezruiz/forms-gtk-progress/blob/master/Status.md

On Ubuntu 20.04, you can run your ASP.Net MVC 5 application using XSP4. Open a console to where you installed your MVC applications, where all folders, Global.asax, Web.config, ... are and run "xsp4 --port 80" or any other port you like and available. XSP4 is an independent web server and does not need Apache to be run. Also, for C# developers, even the MonoDevelop is not in Ubuntu 20.04, which I don't know why, you can still install it and debug your ASP.Net MVC application. You can also debug any WinForm and console application using the MonoDevelop. YOu can run all your application using mono too.