您可以使用 Xamarin 开发 Linux 个应用程序吗?

Can you develop Linux applications with Xamarin?

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

与 Ubuntu 几年后,我现在的主要 OS 又是 Windows。但我可以切换到 Mac.

并非不可能

现在我对 Qt 有一点经验,但对 Xamarin 没有任何经验。 使用 Qt 你可以开发 on Windows, Linux, and Mac and for Windows, Linux, Mac, iOS, Android, Windows Mobile, ...他们很清楚。

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

无法为 Linux 发布我的软件对我来说是一个交易破坏者。能够在 Linux 上开发会很好,但这是可选的。 但经过我的 Google 研究,我只能找到信息和寻求支持开发 on Linux 而不是 for Linux.

据我所知,这不应该是单单一个问题。但据我所知,Xamarin > Mono 并且我没有在 Xamarin 中得到我能在 Mono 中得到的所有东西。

我也不确定未来 Mono 的支持程度如何。对我来说,Xamarin 对 Microsoft 来说比 Mono 本身重要得多。

我不确定这是否可能,因为 Xamarin 基于 Mono,但 Microsoft 是否有可能在某个时候决定不以与 Xamarin 相同的方式支持具有 .NET 兼容性的 Mono,甚至完全取消独立的 Mono?

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

不,Xamarin 不适用于 Linux。这是 Xamarin 团队几年前做的conscious decision

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.

澄清一下,Xamarin 产品系列在 Linux(Xamarin Studio、Xamarin.iOS 和 Xamarin.Android)上不可用,但 MonoDevelop(Xamarin Studio 的基础)和 Mono(Xamarin Studio 的基础)跨平台 .NET 运行时,绝对是。

您可以使用 MonoDevelop 构建桌面软件。 MonoDevelop 站点有很多入门说明:

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

正如 matthewrdev 所说,Xamarin.Studio、Xamarin.iOS 和 Xamarin.Android 不受 "officially" 支持;然而,Xamarin.iOS 无论如何都使用虚拟模拟器(而且我认为 Linux 上的 Xamarin.iOS 到 运行 没有解决方法),但对于 Xamarin Studio(MonoDevelop on Linux,或者 Jetbrain 的 Riders(如何在 linux 上 运行 没有官方支持,link 中也提供了)可以 运行 在 Linux 作为 Xamarin.Studio 的替代品,我分享的 link 解释了如何在 linux 上安装 Xamarin.Android,因此仅对于 Xamarin.iOS,您将需要迁移或双启动或某事,我希望能有所帮助!(我自己停止使用 Xamarin,但是,此环境有助于在 linux 上为 Xamarin 开发!)

Xamarin Forms 似乎有可能在 linux 发行版上运行。在此 reddit thread Miguel de Icaza 中说:

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.

也就是说:Forms 是一个开源工具这一事实目前开启了这种可能性。

以防其他人遇到这个 q/a:情况已经改变。 Xamarin.Forms 3.0 支持 Gtk#(目前作为预览版)。因此,完整的 Linux GUI 支持已启用。

因此,Xamarin 现在涵盖:

唯一希望的是:JS/HTML5 Web App 目标平台,作为 Xamarin 的一部分 :)

是的,从 2018 年中期开始,可以使用 "Xamarin.Forms" 库开发面向 windows/mac/linux/android/ios 的跨平台 GUI 应用程序。基本上,您有一个来自跨平台代码的共享库项目(UI 和其他跨平台的东西),每个平台有一个项目用于特定于平台的代码(Xamarin.Forms 每个平台都有一个后端实现。在Linux,这是使用 GTK)。

但是,使用 MonoDevelop 您只能 develop/build 应用程序的跨平台项目和 linux 特定项目。对于其他平台,您仍然需要使用 Visual Studio 或 Rider to develop/build。

查看以下答案:

GTK 被列为 Xamarin.Forms 支持的 platforms/backends 之一,它允许为 Linux(以及通过同一 GTK 项目的 macOS 和 Windows 构建应用程序)。尽管自 2018/2019 年和 Xamarin.Forms 3.0 以来似乎没有太多发展。尝试了 运行 2 个具有基本 UI 的应用程序并比较了 Windows/macOS 支持的 GTK(与 WPF 和 Xamarin.mac 后端相比),发现 GTK 不值得追求(基本场景失败) .

您可以在 https://github.com/jsuarezruiz/forms-gtk-progress/blob/master/Status.md

跟踪 GTK 进度

在 Ubuntu 20.04 上,您可以 运行 您的 ASP.Net MVC 5 应用程序使用 XSP4。打开安装 MVC 应用程序的控制台,其中所有文件夹 Global.asax、Web.config、... 和 运行“xsp4 --port 80”或您喜欢的任何其他端口并且可用。 XSP4是一个独立的web服务器,不需要Apache 运行。 此外,对于 C# 开发人员,即使 MonoDevelop 不在 Ubuntu 20.04 中,我不知道为什么,您仍然可以安装它并调试您的 ASP.Net MVC 应用程序。您还可以使用 MonoDevelop 调试任何 WinForm 和控制台应用程序。您也可以 运行 您所有的应用程序都使用单声道。