Building Msi's is NOT a no-brainer

Having spent the greater part of last week writing a complex .msi installer I was heartened to see a nice listing of Msi tasks which are non-trivial to implement pop-up today:

Here's some other reading which is interesting if you are venturing into the Msi arena:

A couple of gripes that I have with .msi's... I was disappointed that I couldn't embed totally custom forms into the middle of an installer and that I was unable to programatically interract with CustomActions until the end of the process.  It was also unintuitive as to how I could get the folderpath of where the user was installing the application.  What would have been good was if I could pass the [TARGETDIR] to my custom installation code or at least access it from the saveState hashtable. 


  • You can pass any number of parameters to your custom installer action. I remember passing directory information to the installer we used for the first Terrarium server since we had to specify where to create the database and also where to update the web.config file we just installed.

  • Justin, yes, you can certainly pass any number of params to a custom installer action but, my specific issue is that the [TARGETDIR] environment variable is not available at the time when your custom action code runs.

    You should go back and look at how you get the install path... I'd be be interested to know how you did it. In my case I grab the path of the executing assembly which feels like a dirty hack to me.

  • You can pass the TARGETDIR to your custom action by using a param like this...


    I needed to add the trailing backslash but it's been so long ago that I don't recall why.

    This will make the value of TARGETDIR available in your custom action using the key of "TargetDir".

    string targetDir = this.Context.Parameters["BaseDir"];

    It would be convenient if it were available without needing to do it yourself but it's not hard to add it to the data.

  • David, thanks for that. I tried so many combinations for passing TARGETDIR through to the custom action but didn't get the syntax correct. I was expecting the following to work:


    ... but, I'll try your syntax of:


    ... tomorrow!

    Thanks for the tip :-)

  • This is the third time I've been to your site. Thnx for sharing more details.

Comments have been disabled for this content.