I need a custom MSI action that copies a file from the MSI source directory

I am creating an installer for an aC # windows project using VS 2008. I am trying to write a custom action that copies the settings file from the source directory of an MSI file stored on a file server (for example, \ server \ fileshare \ myappinstaller \ mysetting.xml) on the computer on which my application is installed (for example, C: \ Program Files \ My App).

The settings file cannot be added to the installer, since it will contain parameters that will be unique to the client installing the application.

Does anyone have code (preferably C # or VB.NET) for such a custom action? Also, does anyone know how to get the original MSI location (e.g. \ server \ fileshare \ myappinstaller) as part of a custom action.

Many thanks

+5
installer c # windows-installer custom-action
source share
4 answers

I solved this by adding

/ InstallerPath = "[OriginalDatabase]"

in the CustomActionData of the custom action (in the Custom Actions tab of the installation project) and reading the value using this code in Custom Action:

Public Overrides Sub Commit(ByVal savedState As System.Collections.IDictionary) MyBase.Commit(savedState) Dim directoryOfMSI As String = IO.Path.GetDirectoryName(Context.Parameters("InstallerPath")) 'Do your work here '... End Sub 

Ciao! Stephen

+5
source share

I would recommend that you add the XML file to the installer as one of the components that will be installed. This would be the easiest way and would not require special action.

WiX may be an option for you. It allows you to customize XML configuration files during installation using XmlConfig.

+2
source share

I do a similar thing, but send the default configuration inside the MSI file, and then use MST to add a custom configuration file. It is much more reliable, since everything is "native" to the Windows installer, and I just need to send a small custom MST to each client.

More information on how I do this can be found in the Simplest Solution for Replacing a Tiny File Inside MSI?

+1
source share

Typically, user actions in WindowsInstaller use something from msi tables to put something into any msi table.

In addition, WindowsInstaller-Team refuses any managed extensions for installers, the reasons for this are found everywhere on the network.

But some time ago I found out the extension to create managed user actions for WindowsInstallers that can be used with WiX , which still works, but instead there is a newer solution - a real extension for WiX that allows you to manage custom actions.

0
source share

All Articles