Monthly Archives: November 2006

Building Visual Studio solutions using msbuild in cygwin

I use cygwin extensively and hate switching over to Visual Studio Command Prompt just to be able to use msbuild. I figured out how I can invoke msbuild from cygwin. It’s a neat and easy solution, but I am sure a better solution exists.

Steps to follow:

1. Create a file called vs [See Note 1]

2. Copy and paste the following line in the file:

cmd /k “C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat” x86

3. Save the file under /usr/bin. [See Note 2]

4. Make sure the file is executable. Execute the command

chmod +x vs

You are done.

Test it:

1. Open up cygwin and execute the file.

   cygwin> vs

It will display this message and give you a VS command prompt:

Setting environment for using Microsoft Visual Studio 2005 x86 tools

Note 1: You can use a different name for the file. I named it vs for visual studio.

Note 2: You can put it under any directory you like. If you decide to put it under any other directory, then you you have two options:
1. Add that directory to PATH. OR
2. Give the full path to the directory whenever you execute this file.

Note 3: For some reason the UP key does not work. I need to find a fix for this.

Note 4: I know a better solution exists. The batch file which I execute in the vs file is setting a few environment variables. Instead of invoking this batch file, I should set the environment variables directly. This is a neater solution.

T for two, T for togetherness

Happy moments, sad seconds,
We have seen it all
Our marriage turns two
It stands so tall

Mellow music in darkened room,
You holding me, I staring at you,
Rafi, Sonu, Lata or Asha, who cares,
What we enjoyed was one another

Salty cheeks, wet pillows,
Upset moods, low spirits,
Red eyes from crying all night,
Living together, but like strangers

We have been through all,
And are still together,
That shows the strength
Of our love, our life

We will soon step into
A new phase of life
We will see ourselves
In someone else’s eyes

I will see you, when she smiles
And I will remember you, when she cries
She will be the living proof
Of our marriage and our love

With all my heart and soul I wish,
A very happy wedding anniversary,
Hope our love continues to grow,
Hope it never ceases

Hope to see a new face of our love,
A face which will remind us of each other,
A name which will be sweetest to us,
And a kid which will be OURS.

Larry Wall and the state of his onion

Larry Wall (for those who don’t know who he is: he is the inventor of Perl. For those who don’t know what Perl is: you need medical help!) has a great article on Perl 6.0 release and its features. He talks about why and what Perl 6.0 offers and what it doesn’t offer and a lot of non-Perl things like his family, his grandchildren and the rest. It makes a good, humorous read. It’s 5 pages long, but has a lot of photos interspersed, so it’s actually not that long.

Larry and the state of onion.

Windows Hack: Open an explorer from the command line

With the WinXP Power Toys, you can open a command window at any directory you want.

For instance, if you are deep within the tree of directories and sub-directories and you decided you need to execute something on the command line, right at that directory, all you need to do is right click and say ‘Open Command Window Here’. You get a command window and the current working directory would be the directory on which you right clicked. Nifty, huh?

What if you want the other way around? Say, you are using the command window and you are currently in the directory
C:\Documents and Settings\Administrator\My Documents\My Music and you want to open a window at this location?

Simple. Type the following:

c:\>start .

The dot is for the current directory.

If you are a cygwin user, then stick this statement in your bash_profile or bashrc file.

alias start=”cmd /c start”

and then start away.

cygwin>start .

This ‘start’ comes handy at times. If you have a pdf file which you want to open, type ‘start filename.pdf’ and it opens in your PDF reader.

Bottom line is, ‘start’ is like double-clicking on an icon. You can do a lot of things with it. Try it, it’s addictive.

The generous C#

I found out these amazing facts about C# in the recent few days.

1. new has three different meanings
new operator
new modifier
new constraint

2. readonly keyword is used for variables which are to be initialized only once in the lifetime of the variable. readonly variables can be only initialized when they are declared OR in the constructor.

I was curious about the new modifier applied to members/methods in the derived class which hides members/methods of the base class. As I delved deeper, I realized that the base class implementer has so much control over how its derived classes will behave. More specifically, a base class can enforce these restrictions on its derived classes:

1. Do not allow inherited classes (sealed)
2. Implement a method (abstract)
3. Do not override a method (sealed)

The features that C# provides is much more than one can use. The compiler volunteers to perform a few run-time duties and makes it possible to catch problems that would have resulted in exceptions or crashes or undefined behavior otherwise. If a C# programmer consciously uses the features offered by this generous language, I believe the resulting program will be less buggy.

The more I learn C#, the more I like it.

PS: This article explains well when to use new and when to use override keywords.