Monday, October 15, 2007


What a horrible, yet fascinating, thing WiX is.

Executable context

Sometimes it is known that certain files (the .exe.config in particular) that are necessary for the running of an application reside in the same folder as the executable. Now, if the executable is not run from the directory where it reside it can run into problems locating these necessary files. In this case the following code comes to the rescue:

static void Main()
string directory = Path.GetDirectoryName(Application.ExecutablePath);
Process.GetCurrentProcess().StartInfo.WorkingDirectory = directory;
Application.Run(new Form1());


I just found out about this utility/possibility. Thought it was so interesting that I should make a note of it here: ILMerge. It can be used to take an executable and a dll it depends on and package them into a single executable.

ILMerge.exe /out:complete_app.exe app.exe app_lib.dll

I have one scenario where this is useful for me: I have a program that has both a console and gui (windows forms) front-end. In order not to duplicate code I have 3 project, one for the console part, one for the gui part and one for the common code. In a Wix installer script I need to reference both the gui project and the common dll, but by inserting the dll into the gui executable I only need to reference a single executable in the Wix script :)

True, a marginal improvement, but, still, many brooks make a river :)