Archive for the ‘Linux’ Category.

Custom Nant Task

When using Nant there is not much you can say is lacking. Sometimes you find yourself wondering why you are cutting and pasting good amount of code between different scripts. There has to be a better way of reusing code and sure enough there is. Just write your own Nant extension and it’s pretty simple, let’s take a look.

First create a class that extends the nant Task then declare the name of the task and setup the properties you want available to the user. Lastly you will have ExecuteTask procedure that will be called by Nant when your Task executes. That’s all the magic !

    public class CxSetVersionAssembly : NAnt.Core.Task
        [TaskAttribute(“file”, Required = true)]
        [StringValidator(AllowEmpty = false)]
        public string file
            get { return msAssemblyFile; }
            set { msAssemblyFile = value; }

        [TaskAttribute(“buildNumber”, Required = true)]
        [StringValidator(AllowEmpty = false)]
        public string buildNumber
            get { return msBuildNumber; }
            set { msBuildNumber = value; }

        // Executes the nant task
        protected override void ExecuteTask()
            // Don’t catch errors, it will display in the build log if any
            Project.Log(Level.Info, “start setVersionAssembly”);
            ChangeAssemblyVersionNumber(msBuildNumber, msAssemblyFile);

When you use it in your Nant script you will have to load your assembly first. Once your assembly has been loaded you can start using your custom Task.

<loadtasks assembly=“bin\debug\DE.Nant.Extensions.dll”/>


This is a very brief and simple example, there are bunch of properties and other goodies you can use as you build out your custom Nant Tasks.

The Custom Nant Task I wrote is used to update the version of our .net assemblies during build. Attached is the complete code including Nant script and unittests. Get the code

C# download web page

I’m sure you had the need sometime to download the content of a web page to be able to analyze it or work with the content. Here is a code snippet just for you, we will use simple http GET for the specified URL.

public static string getWebPage(string psUrl)
    WebResponse result = null;
    string sRet = string.Empty;

        WebRequest req = WebRequest.Create(psUrl);
        req.Method = “GET”;
        req.Timeout = 3 * 1000// 3 secs
        // Explicit no caching, usually this is the default
        req.CachePolicy = new RequestCachePolicy(RequestCacheLevel.BypassCache);

        // Has to process the results if the responding service is spitting it out
        result = req.GetResponse();
        Stream ReceiveStream = result.GetResponseStream();
        Encoding encode = System.Text.Encoding.GetEncoding(“utf-8”);
        StreamReader sr = new StreamReader(ReceiveStream, encode);
        // in case the caller is interested
        sRet = sr.ReadToEnd();
        if (result != null) result.Close();

    return sRet;

The LinuxHater

Just a quick one here, it might lighten up your day just as it did for me.  We all know the guy who likes to hate on Linux at LinuxHaters closed shop.  As I sadly pointed out a few months back.  But guess what, he’s back in business get your smile on lusers !

Minix hack to Linux

I just read an interesting post with a reference to a newsgroup post from Linus Benedict Torvalds.  On October 5, 1991 about the new “free version of a minix-lookalike.” Beware it’s only for developers hackers !

Interesting excerpt from the post,

This is a program for hackers by a hacker.  I’ve enjouyed doing it, and somebody might enjoy looking at it and even modifying it for their own needs.

Doesn’t that remain the state of Linux today ?

Linux day#5

I tried to address the Skype issue today, not being able to use skype voice  from the linux box isn’t going to work.  At least not if all the daily tasks are to be included.  I snug over to the Mint forums and used an advise from a thread that gave better results than what I had tried before.  Still my father on the other end in Florida complained about some rattle sound from the mic etc, but a lot better than talking with a muffler on.  It’s usable but it’s not great as it is on the win box.

Then I started to setup the dual monitors, that has only given mixed results.  I was able to activate both monitors but they are still showing the same desktop.  Which doesn’t make it very usable… to be continued.

Linux day#4

I had to review a checkin from a fellow developer in svn, so I fire up the newly installed rapidSvn.  The first complain was something about not able to find the current locale, but it starts, kewl.  I goto the commit log of a file and choose my diff location, next complain you must have external diff tool configured, ok sounds good.

I go google-ing seems either Kompare or Meld will do the job, Meld seems to be better liked and more feature, install is a snap with the Synaptic Package Manager.  So I point rapidSvn to use meld, now I can go differ and get this review over with.  But guess what, doing a diff crashes rapidSvn and it doesn’t matter if I use diff or meld, something fishy going on here.

Another star goes to TeamCity as I can click on the list of changed files since last build further I can do a diff right there in the browser, nice.

In rapidSvn I just get Segment fault, so I use gdb to see if I can catch any debug info, although I don’t have the debug version as google wasn’t to helpful.

gdb rapidsvn
(gdb) r
Starting program: /usr/bin/rapidsvn
(no debugging symbols found)
(no debugging symbols found)
[New Thread 0xb62d0b90 (LWP 18555)]
(no debugging symbols found)
(no debugging symbols found)
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb62d0b90 (LWP 18555)]
0xb7ee46e1 in svn::Status::entry () from /usr/lib/

And after another google, it turns out the rapidSvn version 0.9.4 has a bug#111169 The good news is that you can compare your working copy against the head or a version in the repo to see changes.  I hope 0.9.6 or whatever next stable will have a fix as I don’t want to get the C# source down on the linx box from the repo.

Btw, another thing that’s annoying with rapidSvn, it saves your configuration on shutdown, which means you have to shutdown once in a while to save the latest things you have configured if your expecting crashes like I was.  Maybe there should be a save environment command ?

Now about the other / first problem  ( Cannot set locale to “.  )  whatever that means.  Here we go google-ing again, suprised as I might be that turned out to be pretty easy.  For some people go System -> Administration -> Language Support.  There choose English ( United States ) or whatever is to your liking and you should be good.  In my case when the dialog opened up it claimed that I didn’t have the full language support installed and wanted to install couple of modules, uh sure thing.  After install and forced reboot ( reminds me of win ) I’m all good.