Can you develop Linux applications with Xamarin? - c#

Is it possible to develop and build Linux applications with Xamarin with the same code base?
After a few years with Ubuntu, my main OS right now is Windows again. But it's not impossible that I could switch to Mac.
Right now I have a bit of experience with Qt and no experience with Xamarin.
With Qt you can develop on Windows, Linux, and Mac and for Windows, Linux, Mac, iOS, Android, Windows Mobile, ... They are pretty clear about that.
Since Xamarin is free and open source now and I still don't have much experience in Qt, I'm considering trying out Xamarin for cross platform development instead of Qt.
Not being able to release my software for Linux would be a deal breaker for me. Being able to develop on Linux would be nice, but is optional.
But after all my Google research, I could only find information and people asking for support to develop on Linux and not for Linux.
As far as I know, this shouldn't be a problem with Mono alone. But as far as I know Xamarin > Mono and I don't get everything in Mono I could get in Xamarin.
I'm also not sure how well-supported Mono will be in the future. For me it looks like Xamarin is much more important for Microsoft than Mono itself.
I'm not sure if it's even possible, since Xamarin is based on Mono, but is it possible that Microsoft will at some point decide not to support Mono with .NET compatibility in the same way as Xamarin, or even cancel Mono as standalone completely?
So I'm looking for one single framework for all desktop and mobile platforms I can rely on, and I want to know if Xamarin and/or Mono and and/or Xamarin + Mono could be an alternative to Qt before I go deeper into any of those solutions.

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:
Android
iOS
UWP apps
WPF apps
Linux Gtk desktop applications
Mac OS
Watch OS
tv OS
Tizen
The only thing left to wish for: JS/HTML5 Web App target platform, as part of Xamarin :)

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:
Install MonoDevelop 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.

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

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!)

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.

Related

Porting WinForms app on mac or just develop it again?

I've developed a WinForms application with C# in Visual Studio on Windows and I need a version for macOS but I don't know which way is the best.
I also have a Mac machine so don't have problems about the compiler: I already used VS2017 with integrated Xamarin to develop an iOS app using my mac as the required build server but didn't find any such method for developing a Mac desktop application. NET core only works with console application and even Visual Studio for Mac is different from Visual Studio for Windows and doesn't provide any visual designer. Am I forced to redo the whole application using an Apple product?
There are multiple solutions to building desktop apps targeting a Mac using .NET.
Mono is an alternative implementation of the .NET Framework that reimplements the underlying Windows API calls that Win Forms makes. It's probably the most straightfoward way to port an existing Win Forms app to Mac.
ElectronNET is a combination of Electron and .NET. Electron provides a desktop development framework combining a Chromium rendering engine with NodeJS. It's best if you have a lot of familiarity with web development. It's notable that major companies that want to build cross platform apps are using Electron (Visual Studio Code, Slack, Atom etc) so those with the time to invest in researching how to do a cross platform app seem to choose this option.
Avalonia is a .NET desktop framework that is inspired by WPF, but it's cross platform.
So no, you aren't forced to redo your application. Hopefully you've done a good job of separating UI logic from business logic, which will make using one of these other technologies easier.
Note that even though .NET Core 3 (which is cross platform) has support for Win Forms and WPF, that functionality will only be working on Windows. Win Forms still depends on the underlying Windows APIs, and WPF still depends on DirectX.

Windows Forms C# Pot To Mac OS X (easiest way)

Been searching the web and stackoverflow for 3 days, and I can't find an answer for what I need. I am a C# developer, not a Pro one but I am pretty good with developing Windows (desktop) software.
Now I want to port a windows software to Mac, but I simply can't find a guide on how to do this.
I installed VS coomunity 2015 with xamarin, but I didn't find any tutorials or guide on how to port a desktop software to mac os X (not to ios/windows phone).
I know that using Mono will help do that, but I simply have no clue where to start. I installed vmware with elcapitan, have everything set-up but I have no clue what to do next.
So knowing that I developed a C# .net app, that uses only the default .net libs that are supported in MONO, what should I do to port it on mac os X?
How can I compile in VS 2015 and simply run on Mac OS X?
Thanks a lot!
Vlad
Developing a Xamarin.Mac app is currently not supported in Visual Studio and requires Xamarin Studio running on a Mac with the latest version of Xcode installed.
Windows Forms and Windows APIs are not supported in Xamarin.Mac so you will need to port your UI to NSWindows, NSViewControllers and NSViews. However, you can share the back end code across platforms such as your data models and business level classes. A typical app can share up to 80% of the code across platform.
I would suggest starting with our Hello, Mac documentation as it gives a needed base required for the rest of the Mac documentation.

Can Mono run Windows universal apps?

I'm writing a universal app by using windows 10, visual studio 2015 and C#. I would like to run this app on windows, Linux and mac. I know mono doesn't implements windows presentation framework, so, if I write a WPF app it runs onluy on windows. Now, if I write a universal app, can mono run that? If yes, how?
The holy grail .Net UI question :-)
TL;DR Answer = No.
Universal Windows Platform (UWP) core APIs (also known as Windows Runtime / WinRT) and the resulting APPX based applications only target Windows 10 platforms (Phone, PC, Tablet...) as those APIs and runtime do not exist on the other desktops.
Using Xamarin/Mono you could reuse a portion of the C# app's 'business' level logic but the presentation layer and GUI logic would have to be re-written using a different GUI (Native Widgets, GTK#, QTSharp, HTML/CSS/NodeJs, etc...). Same model that people have been using Xamarin for C# based mobile development applies, share your C# app logic across platforms and use Xamarin.Mac to build a native OS-X UI, and/or build a UI using GTK#, embed your app's runtime logic into a Electron/Blink shell, etc..
Currently the Windows 10 for Apache Cordova project which is HTML, JavaScript, and CSS, only targets Mobile (WinPhone, iOS, Android) and Windows 10 PC/Tablet platforms. That is not to say someone could not develop a new Cordova target to include OS-X and Linux desktop manager support (but I do not know of any that have not already stalled) :-/
Even Microsoft's xplat-based Visual Studio Code for Linux and OS-X uses Electron (Chromium based) to deploy the io.js based application along with the Blink layout engine to render the UI, all done in HTML/CSS/JS.

Learning ASP.NET MVC on Mac OS X

I realize this is a bit insane, C# being a Windows language and all, but I want to start learning C# mostly because I'm interested in ASP.NET MVC. I work as a web developer by day and my office is completely run on *nix machines. The developers and all other staff use Mac OS X and our servers are all some variation of Linux.
To be honest I just want to try something different than PHP, Python, or Ruby. The catch is that I don't want to give up my beloved Mac OS X. I've looked at Mono a bit and it seems like exactly what I am looking for. Unfortunately MonoDevelop is very slow to the point of uselessness on Mac OS X. (Unless I'm doing something wrong which is entirely plausible).
So my question boils down to this: What is the best way to code and compile C# apps on Mac OS X. (Running the code is not that big of issue, I'll probably just get some cheap server space to run my ASP.NET MVC apps on. I'm not really looking to run any apps on Mac OS X.)
In my own experience as a C#/Windows/ASP.Net developer the greatest strength of the platform is the integration with the tools. That said it is difficult to get it all running on mono. Mono would be an excellent deployment platform. But if you want to learn asp.net MVC your best bet is to set up a virtual Windows environment and get the free visual web developer visual studio: http://www.microsoft.com/express/vwd/ .
The other reason is that if you're trying to learn the platform, most resources will use some variant of Visual Studio. I find it rather difficult to try and learn a framework and have to struggle with platform differences at the same time.
I say this as an avid OS X user that has done C# development for several years and has done several small projects in asp.net mvc.
what about running a virtual Windows machine on your Mac?
see http://www.parallels.com/eu/products/desktop/
+1 to Min's answer.
The tools Microsoft provides (free and purchased) are amazing and integrate very well.
The more I use Visual Studio, the more I love it.
I highly suggest doing your dev for ASP.NET/C# on Windows (bootcamp or vmware or w/e).
Having to switch between OSes when you want to code is a small price to pay compared to the potential compatibility headaches you might face in the future.
I'd add to the virtualisation argument. If you were to go for a Windows installation in VMWare Fusion, for example, you can run it in coherence mode. In this mode, you still get all the apps and system you know and love in OS X, and make Visual Studio appear as if tit were a native OS X app. VS, though, "sees" the Windows environment, so you get the benfits of developing on Windows.
Of course, you have the overhead of having two OSs competing for resources, but most of the time this is not an issue (It isn't to me, anyway, and I run my own projects at home this way on a humble MacBook)
In case anyone ends up on this question, ASP.NET Core is now out and runs on the Mac. MS has a walkthru detailing creating a Web API with ASP.NET Core: https://learn.microsoft.com/en-us/aspnet/core/tutorials/web-api-vsc
I concur with a virtual windows machine and VS Express, but Mono Develop is not that bad when especially targeting ASP.NET MVC.
Developing in .net is quite highly IDE-oriented. Of course you can do it all in a plain old text editor but it gets harder and harder unless you're writing back-end server code only. Maybe there are great mono-based IDEs but I can't see why you'd prefer to use MacOS when all the time will be spent using the IDE anyway.
Definitely vote for virtualized Windows or using BootCamp.
You could install a linux desktop on your mac (KDE) and use wine(a linux windows emulator app) to install Visual studio express. The KDE desktop runs on a mac. Now you do not have to install a complete windows os on your machine.

C# in linux environment

I am currently working in C/C++ in a Unix environment and am new to Linux environments. I would like to learn about the Linux OS and learn C# as the next level of programming language for my career.
I decided to put Ubuntu Linux on my laptop. But I am not sure whether we can write, compile and run C# programs in Linux environments or not.
The only IDE I know for C# is MS Visual Studio. Is there are any possible way to work in C# in a Linux environment?
If I have no other option, I'll have both operating systems on my laptop - Vista to learn C# and Linux for the other OS.
Learn Mono.
The Mono Project is an open
development initiative sponsored by
Novell to develop an open source, UNIX
version of the Microsoft .NET
development platform. Its objective is
to enable UNIX developers to build and
deploy cross-platform .NET
Applications. The project implements
various technologies developed by
Microsoft that have now been submitted
to the ECMA for standardization.
You can use the MonoDevelop IDE.
MonoDevelop is a free GNOME IDE
primarily designed for C# and other
.NET languages.
Mono is an open source .NET compiler, runtime and library.
Monodevelop is an open source C# IDE, primarily intended for linux development. It includes a GUI designer.
You can also use wine, which is a free implementation of Windows' API.
For this :
sudo apt-get install wine
then you'll be able to run Microsoft applications and do [almost] everything you like.
EDIT : My mistake, Visual Studio is not functional :-(
A Vista virtual machine in seamless mode running Visual Studio? Then it will appear to integrate into your desktop like any other app, but you'll have the benefit of running the real MS stuff (with C#, having real MS is still a benefit rather than a liability).
I know this is an old question, but I see no one has mentioned Microsoft Visual Studio Code IDE. This could be what you are looking for if you want to do C# in Linux. As a relative NOOB I can say it brings Visual Studio to Linux. If you need a GUI IDE in Linux, this was it for me. see instructions to install it here

Categories

Resources