I require a MSI Custom action that copies a file from the MSI source directory

北城余情 提交于 2019-11-30 21:34:48

I have solved this by adding

/InstallerPath="[OriginalDatabase]"

to the CustomActionData of the Custom Action (in the Tab Custom Actions of the Setup Project) and reading the value with this code in the 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! Stefan

I would recommend you to add the XML file to the installer as one of the components to be installed. That would be the easiest way and would not require a custom action.

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

saschabeaumont

I do a similar thing, but ship a default configuration inside the MSI file and then use a MST to add the custom configuration file. It's much more reliable as everything is "native" to windows installer and I just need to send out a small custom MST to each customer.

More information on how I'm doing this can be found over at Simplest solution to replace a tiny file inside an MSI?

Normally custom actions in WindowsInstaller use something from the tables of the msi to put something into any table of the msi.

Additionally the WindowsInstaller-Team declines any managed extensions for the installers, reasons for that are found everywhere on the net.

But, I did some time ago figure out an extension to create managed custom actions for WindowsInstallers, usable with WiX, that works still, but there is a newer solution on top of that work, a real extension for WiX to allow managed custom actions.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!