65

I'm wondering about best practices to develop ASP.NET MVC apps with an option to deploy on Linux. If you are creating these kinds of MVC apps,

  • What Linux/Mono platform are you targeting?
  • How much of the development are you doing on Windows and how much on Linux?
  • Are you using an ORM to abstract the database? Which one?
  • Are you running a build engine on Linux? What about tests?
  • What other tools are you using?
  • How much additional work has it been to target Linux in addition to Windows?
  • What ugly or pleasant surprises have you encountered?
Cœur
  • 37,241
  • 25
  • 195
  • 267
keithm
  • 2,813
  • 3
  • 31
  • 38
  • Sounds like this question should be a community wiki. There is not going to be one right answer. – mkchandler Jul 23 '09 at 15:35
  • 2
    Agreed, there may not be a single right answer, but since deploying to Linux requires us to assemble more components in a a non-native environment, it's worth hearing from those developers who have actually done it or are in the process of doing it. – keithm Jul 23 '09 at 15:46
  • I was tempted to say "Surprise! it won't work!" but I'm just having my own issues implementing a larger project. Mono is honestly spectacular. Just thought that would give a few chuckles to those that are still trying to understand the cryptic errors Mono can sometimes throw up :) – Chazt3n Feb 12 '13 at 23:13

3 Answers3

34

The company I work for targets Mono on Linux as our main deployment environment. Thus there is no "additional" work - we provide the whole stack, from hardware, through operating system (customized and trimmed) to applications. Using Open Source gives huge savings for us and our clients (and yes, we do contribute back to the OS Projects we rely on).

The important thing is to constantly test using your actual target (sorry, Mono on Windows doesn't count). Sure, developers use Visual Studio, but the continous integration (using CruiseControl.Net, you'll need Mono 2.4.2 to run it on Linux) is done both on Windows and Linux, testing all Mono versions we expect to work on (it got much more stable recently, but still, regressions do happen between releases). It's quite easy to run parallel Mono versions on one *nix system, you can even include an svn snapshot build if you prefer to catch upstream regressions early. If you don't roll out your own distribution, then remember that most Linux vendors ship Mono with custom patches - this has caused problems for us before. Also, many distributions have a lot of lag updating Mono, and this is a rapidly advancing project.

For database layer we use mostly "plain" ADO.NET - Oracle (with dotConnect for Oracle, they support Mono) and SQLite (Mono ships with a working connector). I have also used the official ADO.NET Driver for MySQL (Connector/NET) and it, too, works well. ORM mappings are more tricky, but NHibernate is usable (keep in mind that they do not support Mono officially).

As for the build engine and tests - NAnt and NUnit are well known and well tested. With most recent versions of Mono xbuild (clone of MSBuild) actually got usable, but prepare yourself for contributing quite a lot patches if you decide to use it for more complex scenarios.

Write tests. Lots of them. Be prepared to contribute patches and bugreports, and if you use commercial components - make sure the supplier officially supports Mono.

skolima
  • 31,963
  • 27
  • 115
  • 151
  • Thanks for a great answer. What's your database and data access software? – keithm Jul 24 '09 at 05:08
  • Thanks for the information. Are you still working this way? If so, have you updated to newer versions of .NET and MVC? Also, are you using any ORM software such as Entity Framework successfully? It's been a few years since your answer, so I'd like to know that you're still as positive about the tech stack now as then. Would you still recommend CC.NET, NAnt, NUnit, etc...? Thanks :) – Drew Noakes May 15 '12 at 21:32
  • MVC should work great - it's now opensourced and MS is taking patches from Mono! I'd now go with MSBuild instead of NAnt, but NUnit is still a good choice. CC.NET Mono support has been a little neglected, that should improve soon after upcoming 1.7 release. And unfortunately I have no experience with ORMs on Mono - but there are other answers on SO on that topic. – skolima May 16 '12 at 07:50
  • what about EF ? , open source as well as microsoft product – Vishal Sharma Dec 27 '13 at 15:47
4

Nathan Bridgewater's blog has some nice articles showing, among other things:

  • running MVC3 with razor on mono
  • migrating ASP.NET MVC from Windows/SQL Server to Linux/MySQL
  • installing and running MonoDevelop
  • installing mono from source

http://iws.io/get-mvc3-razor-running-on-mono/

Drew Noakes
  • 300,895
  • 165
  • 679
  • 742
1

Take a look at the Mono project. Sounds like that is what you are looking for. If I remember correctly, they have ASP.NET MVC integrated into it now.

I have never worked with Mono, but from my understanding there are not many differences.

mkchandler
  • 4,688
  • 3
  • 23
  • 25