Monday, February 13, 2012

Wrangling Setup (msi) projects

To add a custom action to a Setup/Deployment project, you can write a stand alone script (in VBS), or write a standalone executable, or you can add an Installer class to your main application. I like the last one, since it keeps everything together in less files.

1. Add an "Installer Class" to your project using the Add New Item

2. Override the 4 class: Install, Commit, Uninstall, Rollback.

3. If you want to do any logging, use this.Context.LogMessage(string)

4. If you want to use passed parameters, use Context.Parameters

5. Build

6. Add the application as a Custom Action to your setup project. Add it to ALL 4 actions, otherwise you'll get an obscure error.

7. To pass parameters, use CustomActionData field, and format it like /name=value /name=value. Use double quotes if you have spaces in the values.

8. You can make it conditional by
a. adding a Checkbox to the user interface, and naming the property of the checkbox, ie DO_WHAT_I_WANT
b. Using that checkbox name (ie DO_WHAT_I WANT) as the Conditional of the custom action.

9. To debug, Use
System.Diagnostics.Debugger.Launch();
System.Diagnostics.Debugger.Break();
where you need it.

No comments: