Deploy Mono application without Framework on Mac - c#

I have a c#-program, that works well under Mono and on OSX, I also was able to create an app-directory for that program. Now I want to distribute it, but I don't want to force the user to install mono, since this is unusual under Mac (and has some side-effects, that I want to avoid).
I already tried to build a bundle with mkbundle, but mkbundle doesn't work correctly under Mac.
I should add, that I use GTK.
What is the easiest way to build a compleley independent app under Mac? Is there any good tutorial? Is there a good tool, that could help?

Ask Miguel (December 9 2010 blog post)
MonoMac: we just released MonoMac 0.4 and we are now adding support for creating self-contained application bundles that developers can redistribute themselves or even submit to the Apple AppStore for MacOS.
MonoMac has been a lot of work, mostly, due to popular contributions. There is a nice emerging community of new contributors to Mono that has sparked in the last few weeks.

Did you try macpack?
http://www.mono-project.com/Guide:Running_Mono_Applications

It should be possible to use mkbundle in the linking of mono assemblies to produce a "portable app" with no requirement on installing the runtime.
http://www.mono-project.com/Linker

Related

Importing winform solution to mono (linux) from VS Code (windows)

I tried to import a winform solution file from VS code (windows) to monodevelop (Linux) but it failed. The error is as follows:
Error while trying to load the project '/home/virtuall_kingg/Camera_GUI/Camera_GUI/Camera_GUI.csproj':
File not found: /home/virtuall_kingg/Camera_GUI/Camera_GUI/Camera_GUI.csproj
I added Camera_GUI.csprojfile also but still the error is same.
Can anybody guide me on how to import solution to mono?
This winform project has become pain in my neck.
Is building the GUI using gtk# in Ubuntu from scratch is the only way?
EDIT: Now you can substitute mono with .NET 5, the common .net framework for all platforms.
You are asking multiple questions here. In Linux you have (limited) support for WinForms through Mono. Depending on how complex is your project, you could port it without modification. If there are p/Invokes, then you won't for sure be able to port it.
Yep, in Linux the "other" big option is Gtk#, which has a long history. If you would want to port the project starting from scratch, it'd be a good option, but it'd involve porting your classes from working with WinForms to Gtk#, which is not impossible, but not trivial either. The feasibility of this would mainly depend on how good that project is architected. Do you have bussiness logic and views separated? If the answer is no, then the process will be tedious, and as hard as lengthy.
MonoDevelop is an IDE for C#, and Visual Studio for Mac is roughly MonoDevelop. It certainly works in Linux... as well as Visual Studio Code. So, there is no need to change anything in that front if you just need to port your code to Linux.
Okay, now, what's the road to follow? I think the best one is to try Mono with WinForms. It'd maybe involve simplify some code in the user interface part, but is certainly feasible. Just remember that you need to install Mono, and if your project is set to target .NET Core, then you need to create another project from scratch and set it to target .NET Framework.
Now, the specific question is that MonoDevelop complains about a missing Camera_GUI.csproj. This means that you've only picked a few files, but not the whole solution. Any IDE (Visual Studio, Visual Studio Code, Rider...), would complain about the same thing. Either remove the project from the solution, or add the project with all its files to the directory in which the solution sits.
So, the answer is: don't change anything if you don't need to retarget your project. Just move to a Linux box or virtual machine, with the whole project and open it in Visual Studio Code Rider, Rider, or MonoDevelop it does not matter. From within the IDE, remove those projects that make no sense in Linux (i.e., windows installer), and then recompile and start the program. Polish those parts of the user interface that need tweaking and that's it.
Should you need more help, please be more specific and provide more info.

Can Windows and Linux developers work together on the same project using C# and ASP.net?

If a group of developers are working on a project written using ASP.net and C# in a Windows environment with Visual Studio, is there any way a developer can join their team and work with them on the project in a Linux environment? I know about the open source, cross-platform development framework Mono, could this be an option or would the Windows developers have to use this as well for that to work? Is the best option for a Linux developer to just install a Windows partition or can he join them without doing so?
Is the best option for a Linux
developer to just install a Windows
partition
Yes, by far. Even better, just get a PC. I've run into so many headaches trying to develop in .NET on Linux. Mono isn't perfect, and never will be.
Yes! Use MonoDevelop and a source management solution like Mercurial.
Yes, MonoDevelop can even load the Visual Studio solutions.
It deppends on many factors, I'd say that if you plan to use third party controls, for example, then you probably better stick to windows and visual studio. If you are going to do P/Invokes (call Win32 api methods) then, again, better stick to windows.
The fact is that many functionality that .Net framework has is only available on the Microsoft redistributable installer/visual studio installer etc. If you are joining a team that already has a project going on and it is linked to any of this namespaces (Microsoft.* comes to mind) then definitely install windows and visual studio, on the other hand, if you are just starting a new project it could be easy to develop on linux with monodevelop as long as you stick to anything that is fully supported by the mono framework.
Another thing you should consider are licenses. If your team already has visual studio and windows licenses it does not make much sense to switch to linux, as much as I love linux and mono/monodevelop the best way to develop for .net is the microsoft stack without a doubt.
What makes sense is to try to comply with mono so that your software can run in unix/linux infrastructure if you already have it and if switching it to windows server, for example, raises the cost too much.
It's all about the cost, unfortunely, so see these tools just as that, tools, they are the means to an end and just that. If developing and deploying with windows and to windows is cheaper then go ahead, if you have a large unix/linux server set already working and want to deploy into that then use mono, just consider it has a slightly learning curve since it is NOT visual studio/.net per se.

Developing with C# on OSX and Mono

I'm about to start a project that requires me to write c# code. The thing is, I've got a mac.
I was wondering if there are any pitfalls involved in c# development using mono on OSX 10.6
I think the page is clear that the implementation is crisp, but on the other hand I've read that people install VMWare or something like it to use Windows. I'd like to avoid that if possible.
Note
I'll be working on a team and all the
other guys have Windows machines
Thanks
Based on your comment to HiVoltRock's answer (ASP.NET development), I'd say Mono 2.10.1 and MonoDevelop will be just fine (the stable release of MonoDevelop works just fine, but for development on OS X I prefer to use the most recent version which I compile from Git).
There are some things to take into account, such as file paths (ie: if the windows devs are writing static paths such as ApplicationsInstallDirectory + "\data\templates\foo.bar"; you will run into problems as directory separators on Mac OS are forward slashes. Also if existing code is using P/Invoke or other specific Window's functionality you'll be in trouble.
Finally if your code base uses third party libraries that requires Windows this could cause you issues.
For reference our product has been designed since day one with a requirement that it runs on Mono on Linux or OS X. With that in mind we've made sure to consider everything with cross-platform execution in mind. If you're joining an existing product, the same considerations might not have been given, meaning a lot of the existing code isn't compatible with Mono.
The Mono Migration Analyser will help determine if you've got any incompatible code.
There is a bit of fud out there about developing under Mono. Our project is an MVC3 with Razor, running .NET 4 using NHibernate, StructureMap etc and there haven't been that many issues developing on a non-Windows machine.
Be aware that the .NET libraries from Microsoft and the implementations in Mono are compatible "most of the time." If you're working in a team, you may run into some headache related to these compatibility issues (also, if you're using any third party plugins to any .NET application you're writing, you may have issues as well.). If you didn't want to run a virtual machine, I'd just bootcamp into Windows. It might disrupt your flow if you're very used to the OSX UI, but if the rest of your team is using Windows, I'd do that just to avoid compatibility issues.
The biggest thing I've had developing on Mono (admittedly on Linux) was GUIs. The majority of GUI-less code will run just fine. The only thing I've had to do is catch a few different exceptions. GUIs, however, would be a whole different beast, so don't expect those to translate well at all.
I would highly recommend using windows thru vmware rather than trying to code with some unstable osx programs. It's not cool to code for hours on a mac and then realize that none of your code works on any windows machine or that the gui looks totally different than on your computer.Always choose the right tools and languages for the right problem. Besides, visual studio is pretty nice to work with most of the time.
I've come across odd cases of memory leaks and segfaults with code compiled on Windows and dropped onto a Mono Linbox as-is. I've also had issues compiling .csproj files with xbuild that had some MS quirk that xbuild wasn't familiar with.
If I'm not mistaken, the two compilers do slightly different things at times, which are related to subtle implementation differences in the runtimes. This is most likely the cause of the segfaults and memory leaks I've come across.
My bottom line is, compile on the same platform as the runtime. So for local testing, you should be fine (you compile on mono on your mac and run/test with mono on your mac). But don't build the project on your mac and then release the resulting Mono binaries to Windows servers running MS .NET runtime (or vice versa). If you have a build server best would be to stick to that (which we all should do anyway... right?).
If your team doesn't have a build process and you must build the binaries you are going to release, I would use a Windows VM for that final step.

Mono on Windows (And General Questions)

I installed MonoDevelop on Linux and wrote a shell GTK+ application. When I compile and run the application shows up correctly in Linux. When I move the .exe over to Windows, I get a crash "Windows Not Responding", so there is no stack trace. Then I figured I had to install Mono For Windows, so I did that, but no luck - I still crash.
More generally, I am having a hard time picturing what is going on here. Please disabuse me of whatever I get wrong:
People who started the Mono project wrote their own compiler (likely from scratch) to compile C# code. They modeled this after looking at the .NET Framework
They also wrote a CLR for their mono implementation of the byte code. Any architecture that wants to run this code will need the Mono Runtime, as only the Mono Runtime can run the code.
Do I have it right? Why doesn't my program run? Thanks in advance.
Three things stand out to me:
GTK+. GTK isn't part of windows or mono on windows by default. You must install it separately.
Shell Application. That means something special in the windows world (an app that runs as part of (extends) the windows desktop shell, rather than as it's own program), and I wouldn't be at all surprised to hear that these don't work cross platform very well or even at all. I'd assume you mean "Console Application" instead, but then why the need for GTK+?
Mono. Make sure you invoke the program using mono. Just because mono is installed doesn't mean that's how your program will run vs Microsoft's own .Net implementation.
Hey, I'm only vaguely familiar with Mono myself but I -think- there is an analyzer tool that will show possible portability issues. If you run through that does it show any issues?
Few things you also check.
Is mono installer contains GTK# libraries.
If yes, check that is the assemblies are in GAC. The assemebiles names be gtk-sharp.dll, gdk-sharp.dll
If no, copy the referenced assemblies in your bin directory. you can see that in your mono develop project.
I assume you mean you wrote a GTK# application. In that case, to run it on Windows, you need to make sure you install "GTK# for .NET" from the Mono Downloads page
On Windows, you can capture a crash dump and see what causes the crash. For example, use WinDbg to execute this application.
http://www.microsoft.com/whdc/devtools/debugging/default.mspx

How to get started with Mono in Linux for a beginner?

How do I start using Mono in Linux as a beginner when I want to switch from Visual Studio?
Is there some easy way to install it like Visual Studio and get started?
So far,with what I've seen,it looks complex to even get started.
Installing and configuring Mono in linux is a lot of work right?
or Is there some distro which I can directly install and get started with applications in Linux?
I recently started to dabble in Mono myself and have so far realized that the MonoProject has made huge advancements in this area. It's well worth it to investigate.
With that said, the easiest method is to get setup with a Linux distro that is Mono friendly such as Suse, or Ubuntu. Personally, I tried it using Ubuntu 8.10.
Once you've got your Linux distro setup properly download and install MonoDevelop. This is an open source IDE that's tightly integrated to work with the Mono platform. MonoDevelop was taken as a branch of SharpDevelop and designed to work with the Mono compiler from the ground up.
This is by far the easiest and fastest way to get setup with Mono. The MonoDevelop IDE is very similar to that of Visual C# Express even. It comes complete with Project/Solution management, GUI development using the GTK# framework, an integrated debugger and a host of other features you would expect in an IDE such as code-completion, line numbers, code-folding etc.
The folks at the MonoProject are on to something with this suite of tools.
Hope this helps you get started.
Mono Project Homepage
Mono Develop Homepage
There are a few interesting books on Mono, although they're probably a little bit old. Still, probably it's worth to grab one and take a look in order to start up.
Practical Mono
Mono: A developer's notebook
Cross-Platform .NET development
Mono Kick-start
Then, I'd install latest Mono (2.4) on a Linux box (OpenSuse is the one they use, so it will always go smoothly for development, but we also use Ubuntu internally) and start playing around with the compiler, MonoDevelop (which is quite good since 2.0) and so on.
The only tough point will be writing GUI applications, although my team make extensively use of MWF on different Unix flavors. But everything else will go as you'd expect. I'm specially happy with how great remoting works, for instance.
If you're used to Linux then it will be much easier, otherwise I'd also recommend you getting used to it following some tutorial.
Remember tools such us NUnit and NAnt will be also available, so you can start writing your code on both Windows and Linux and testing and compiling on both platforms.
With the just released Ubuntu 9.04 a very current Mono development environment is as close as:
apt-get install monodevelop
I used to agree with you that it was somewhat difficult to get going with Mono, but the latest version of Ubuntu has melted that barrier away. And the latest version of Monodevelop is an absolute joy to use.
Don't use Ubuntu? Then I would go with Peter's advice of using a VMWare image.
For a very easy start with mono under linux u can download
a vmware image
a linux live distro
with everything included to start.
If you are accustomed to using visual-studio, you can still develop in Visual Studio, and copy your binaries to Linux/OSX or whatever. Or even better, if you have a shared drive, just reconfigure your VS-Project output directory to the shared location.
There might be advantages to using the mono compiler, or monodevelop, but since you are getting started, the above is really the easiest thing to do. If you want to run on Linux, the mono installer is an excellent option for getting up and running in a hurry. Unfortunately, there's no installer available for the newest mono release, so you'll either need admin permission, or need to compile from source.
http://ftp.novell.com/pub/mono/archive/1.9.1/linux-installer/2/mono-1.9.1_2-installer.bin
For installing newest Mono 3.2.5+ with MonoDevelop 4.2.1+ it is better is use tpokorra repository.
The simplest way I could find is to download the OpenSUSE VMWare Image on their site and just run it. You get all the tools you need :) Preconfigured.
Debian and Ubuntu, and probably all other children, have mono in the repository. So, setting up mono in Linux can be as easy as
aptitude install monodevelop
However I would suggest version 2 which requires using the 'sid' repository in Debian (don't know about Ubuntu).
vim /etc/apt/sources.list [ :%s/squeeze/sid/g ]

Categories

Resources