deploying a portable Mono app

April 22nd, 2009

The obvious advantage of coding in a byte compiled framework like .NET is that you don't have to mess with native dependencies (at least if you play your cards right). That makes your application maximally portable, just download and run anywhere the runtime runs.

So far so good, but if you get to the point where you want to offer more than just a zip file then unfortunately you have to deal with the tedious specifics of how applications are supposed to be installed on any particular platform. Granted, a portable app runs from anywhere, but what about launchers and shortcuts and whatnot?

solarbeam_createshortcuts

Well, one way of doing it is to tell the user "chuck the app anywhere" and then set up the links from within the app, wherever it may be on the filesystem. While a little unconventional, it obviates the need for a special installer app (which you don't need anyway cause you're not really installing).

What about moving the app? No problem, just overwrite the shortcuts.

On Windows

Let's start with the basics. How do you create a shortcut on Windows? It should be a trifle, right? Wrong, my young friend. This is .NET, we love making stuff surprisingly difficult. It actually takes tons of ridiculous voodoo, all of which is very unportable (I wonder if you could even get this to compile on Mono). The file format is binary (why make it simple, right?) and noone seems to know exactly how it works (although some guy tried to reverse engineer it), so you can't just write the 5 lines of code it should take and be done.

Fortunately, there is a simpler way. Instead of making yourself a .lnk file, you can get away with a .url file instead. It's a text format and it's simple. And it seems to work just as well.

So, create a .url, stick it on the user's Desktop and in the user's Start Menu (thankfully .NET does give you a way to lookup those paths).

On Linux

On Linux it's not immediately obvious where to look. As is often the case, the information "is out there", but where? freedesktop.org. But what have we here? A public specification? How delightfully convenient.

It turns out, though, that you need more than just a .desktop file. The .desktop file is sort of the "reference" to your app, but in order to stick it in the menu you need a .menu file too.

So, .desktop file goes into ~/.local/share/applications, .menu file goes into ~/.config/menus/applications-merged.

EDIT: It seems you don't even need the .menu file.

Have I missed anything?

:: random entries in this category ::

4 Responses to "deploying a portable Mono app"

  1. Gen2ly says:

    Well if you want a Desktop icon to go with the .desktop file in Linux it has to be added to /usr/share/pixmaps - there is no support for local icons in ~/.local/share/pixmaps/.

  2. numerodix says:

    There's a directory on my box called ~/.local/share/icons... In any case, it's easy enough to point the .desktop Icon entry to the icon wherever it happens to be on disk alongside the binary.

  3. Gen2ly says:

    Look at that! Just build a directory there and added an icon. Good news, never heard before a local place for having icons.

  4. [...] » GPL vs BSD, a matter of sustainability 1y (1) "but it’s no longer free for anyon.. -Reashlin » easy peasy full system backup 9mo (1) i think you really need very good b.. -digirandi » Michael Jackson is a woman (?) 2y (3) WELL YOUR A.. -breanna | you are a f.. -breanna « deploying a portable Mono app [...]