Stephan Dekker

If you are out to describe the truth, leave elegance to the tailor. (Albert Einstein, 1879 - 1955)

Running a .NET console app on SUN Solaris

For one of my customers I needed to run a financial risk calculation on a Solaris box. The original app is written in C# .NET and targeted for Windows usage. Given my 2 previous posts, it shouldn’t come as a surprise that I choose to use Mono to run the app on Solaris. The whitepaper said I could, so sure it will work.

As said, I created a Ubuntu VM in about an hour(!), configured it in another hour and was ready to do the actual Mono work. Ubuntu has Mono installed by default, so all I had to do is compile the app (and run DotFuscator, just for good practice) , copy it to the linux box via a fileshare on my physical machine and copy it to a folder on the linux box. Happy days, it all works fine.

With that POC working, I ticked the box for managing risk around running the app with Mono and running Mono on Linux. The latter was actually only ticked half, as it was pre-installed, but being a poor dev and not sticking to proper Agile practices, I ticked the box anyway J

I got the login details of the SUN box, which I didn’t have to install and configure luckily. What I read and have heard, Solaris is a whole different installation experience as opposed to Ubuntu. I’m not sure if SUN has the ability to download a Solaris box as a VM, but I had the real thing and a powerfull one as well, so why bother with VMs.

Another happy moment, was when I got the choice of logging in with console or through the XWindows. XWindows please, thank you! J

First thing after logging in was to open a console and try “mono -?” Doohh!!!! No Mono!!!

Off to the Mono-project website to see what they are saying about this topic:

http://www.mono-project.com/Other_Downloads

Basically you need to install a tool to install other packages, so it’s sort of the open source “Windows installer” tool. The installer tool uses the underlying “pkg-get” (The “Windows installer service”) to actually install the packages (MSIs). The difference is that the unix tool uses a list of packages you can install. In our case you can invoke it like: “TheInstallTool –i mono” and it will install mono.

The tool is called “pkgutil” and can be found on: http://www.blastwave.org/. On the first page there is a little bit hidden link, called “READ THE HOWTO”. CLICK ON THAT!!! This will take you to a page of instructions.

Step 1: Be Patched Up To Date

I didn’t know: A) how to do this, B) wether I was or needed to do it in the first place. So I assumed I was up to date and soldiered on...

Step 2: Install pkgutil

That’s the tool we need to install. Make sure you’ve got the correct version of the script, but in my case I ran the following commands:

·         uname –a

·         cat /etc/release

·         pkgadd -d http://blastwave.network.com/csw/pkgutil_`/sbin/uname -p`.pkg

·         mkdir /etc/opt/csw

·         cp -p /opt/csw/etc/pkgutil.conf.CSW /etc/opt/csw/pkgutil.conf

You should end up with an exact copy of the log up on the blastwave website. I actually had one error/warning that the /etc/opt/csw already existed, but that did stop me from continuing.

Step 3: Fetch the Software catalog

Makes sense doesn’t it? When you have an app that can install from a catalog, to download it?

/opt/csw/bin/pkgutil --catalog

Step 4: Security First!

Yeah right, on to step 5...

Step 5: Before you proceed...

Don’t mess with the root account... yadda, yadda, yadda... Ok, I’m done.

Well, as it turned out. I wasn’t. The very important bit is in the second last paragraph, to set the path: PATH=/opt/csw/bin:/usr/sbin:/usr/bin:/usr/dt/bin:/usr/openwin/bin:/usr/ccs/bin

That took me an hour to figure out where the bloody hell Solaris installs the files. Hiding details is great until stuff goes pear shaped. Also RTFM applied, very true. Let’s call it a draw.

At that stage my “mono –?” did return me something! Not sure anymore wether it showed me the Man page or complained about incorrect commands, but the mono command was found and that meant: On to the next stage!

I copied the DotFuscated, on windows compiled to the “All CPU” target,executable (the bin/debug/MyRiskConsoleApp.exe"/ to a filer in the cloud. Went back to the SUN box, opened Firefox and copied it from the filer to the machine.

I’m sure you can imagine that I was very excited when the command: “mono /users/sdekker/Desktop/MyRiskConsoleApp.exe 1000 2” didn’t came back with errors, but with the calculated results!

I explained the coolness to my wife, but I don’t think she really grasped my excitement of it all... J

Another job well done, Stef!!

Published Sun, Dec 20 2009 4:01 AM by Stephan Dekker
Filed under: , ,