Archive for April, 2009

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?