Gerard Braad

F/OSS & IT Consultant on Openness and Interoperability

You can follow more frequent updates via my Identi.ca profile (feed).

Tuesday, March 31, 2009

Using Mono 2.4 on coLinux to ease .NET development

Currently I deal a lot with .NET development in my daily work. Most of the development is done on Windows. When you need to develop cross-platform .NET you would like to use Mono. Mono is binary compatible with .NET and allows .NET applications to run on Linux distributions. If you would develop from Visual Studio you want to easily test the binary directly in a mono session on Linux!

To test software both platforms in a convenient way mostly virtualization is chosen. Of course you can use VMware or VirtualBox when you use Windows, but you can also use coLinux. coLinux is a port of the Linux kernel that allows it to run cooperatively alongside another operating system on a single machine. My choice of distribution to use on top of coLinux is the open version of SUSE, both supported by Novell.

This description does expect you to have understanding of a Linux environment and administrative rights on your Windows system.

Installation (Windows side)
First of all you would need to coLinux installer. This file is available from the coLinux website. The downloads section will point you to the latest stable, as of writing v0.7.3. On the website of Henry Nestler you can also find development and daily builds for 0.8.0. This installation is pretty straightforward, just keep the default settings. When the installer asks you 'Hardware installation' you need to press 'Continue anyways', this will allow the TAP network driver to be installed.

To use a desktop environment from coLinux you need to install a X server. The more difficult way would be to use Cygwin/X... this way you will have a complete GNU system running on top of Windows to provide a Linux-like experience. The fastest and easy way is to use a tool like Xming. The installer you need is the Xming or Xming-portablePuTTY (Mesa is not needed). Also, this installation is quite straightforward. After the installation start the X server from the start menu (Programs → Xming → Xming).

In the posting 'openSUSE 11.1 on coLinux' I described a way to make a base installation of openSUSE for use with the coLinux environment. The file 'colinux-opensuse-111.exe' (113Mb) [VIPeers] [dropbox] contains all you need to run the openSUSE environment. As you can see from the size, it contains only a base system. After you have extracted the file, you will still need to perform some additional installations to make the Mono development work.

Before you start the Mono installation inside the coLinux environment, you need to reserve a directory for your development files or some other shared directory. I choose to use 'D:\Development'. In the run.txt file in the openSUSE directory, you can add a line which says:

cofs1="D:\Development"

This will later be mounted inside the Linux environment.

Installation (Linux side)
Now you can start the environment from the 'runonce.bat'. This one time start is needed to finalize the installation (describe in the 'openSUSE on coLinux' posting as the post-install). You will see something similar to:

openSUSE 11.1 started on coLinux 0.7.3

Logon using the credentials: 'root' and the password 'password'. Immediately change the password using


passwd


Enable the network using the command:


for i in 0 1
do
cat > /etc/sysconfig/network/ifcfg-eth$i << END BOOTPROTO='dhcp' STARTMODE='auto' USERCONTROL='no' END done


Add a mount point to your shared directory


mkdir /media/Development
vi /etc/fstab


and add the following line to this file


cofs1 /media/Development cofs defaults 0 0



To enable the shared directory you need to mount it


mount /media/Development



You can now shutdown...


shutdown -hn now



... the system will halt and closes the console. From now on you are able to start the environment using the normal 'run.bat'. Do so and log on using your new password.

Your network should now use eth0 as a serial line and eth1 as a bridged network using the device called 'Local Area Connection'. If your Windows network device is called differently, please change it in the 'run.txt' file. IP addresses are assigned using DHCP. The device eth0 will probably be assigned the address 10.0.2.15/24. For device eth1 this will depend on your local network settings. I will just assume that eth1 is configured and provides the Internet connection.

To allow packages to be installed you would need to add the standard repositories to this installation.


zypper ar http://download.opensuse.org/distribution/11.1/repo/oss/ openSUSE111
zypper ar http://download.opensuse.org/distribution/11.1/repo/non-oss/ openSUSE111_NonOSS
zypper ar http://download.opensuse.org/update/11.1/ openSUSE-11.1-Updates



Enabling the User Interface
You can use a full-blown desktop environment as GNOME, but since coLinux does not provide a framebuffer device it is not advisable at the moment. We will use the Xming as the X server for our desktop. The X protocol is a client/server model for user interfaces. To keep the installation small, we use a very lightweight Desktop Environment on top of X, namely LXDE.

Install the LXDE packages using:


OCICLI http://download.opensuse.org/repositories/home:/swyear/openSUSE_11.1/LXDE-desktop.ymp


This will start the One-Click-Install. You will need to agree to some questions and lean back... this might take some time.

If this finished, you can test if the installation finished correctly. You will need to set the DISPLAY parameter to specify where the X server is running. Now let's start the appearance settings...


export DISPLAY=10.0.2.2:0.0
lxappearance


and choose a theme that suits your current Windows theme.

LX Appearance

This means your desktop environment works.

If you would receive a 'Gtk-WARNING **: cannot open display:' this means your connection might be blocked for some reason. Check your settings or disable a firewall/virus scanner.

Mono installation
Mono will provide a Linux/Unix system with support to run .NET applications. Originally this description was written to use Mono 2.2 which was provided from the openSUSE repository. To install these packages issue a simple


zypper in -t pattern devel_mono


would be sufficient to install a development environment. To start the Monodevelop you can start this using the command:


export DISPLAY=10.0.2.2:0.0
monodevelop &



Monodevelop

Since the 30th of March a newer release of Mono (v2.4) is available. To install you will need to specify the mono repository and upgrade the previous installation.


zypper addrepo http://ftp.novell.com/pub/mono/download-stable/openSUSE_11.1 mono-stable
zypper refresh --repo mono-stable
zypper dist-upgrade --repo mono-stable



You can now start Monodevelop 2.0 and use managed debugging!

That's it for now... In later posts I will automate the startup and show how to do development using this environment.
Have a lot of fun...

Notes
If you think VMware provides a better solution you can make use of the files that the Mono Project provide in their download section. Either download the generated VMware image of the LiveCD.

If you want to use GNOME as your desktop environment you are advised to remove the gnome-screensaver package and it's dependent, since it can cause issues during use. If you want to experiment with the LXDE environment, you are advised to use the lxpanel and pcmanfm. In a later post these will be explained in more detail.

1 comments:

Ian said...

I have a lot of respect for what you do. I don't even know how to change one widget which is causing a problem on my blog.

Followers