0
votes

I have created an MSI file, but I want a specific C# method in the file to be used in a Custom Action that takes place prior to the ExecuteAction action in the InstallExecuteSequence table. Is there any way for me to update the Binary table in Orca so that it references a particular method in the MSI file?

For more information, my MSI file uses three separate C# class library projects. The method I want to use in the Custom Action is called InitialAction and is in a CS file called Initialise.cs in the Initialise project.

1
As Phil states, the best question to ask yourself when making a custom action is: can this be done better and more reliably in the application itself on application launch? The application will always run in the expected context (user) and potentially with UAC elevation or not (preferably not). An MSI has complex sequencing, complex conditioning (what sequence to run in), complex impersonation (sometimes running as LocalSystem) and complex custom action implementation details overall. Emulated custom actions add another layer of unpredictability to the whole equation. Try to avoid CAs.Stein Åsmul

1 Answers

2
votes

No you can't. Windows Installer doesn't natively support managed code custom actions. The Dll type referred to here:

https://msdn.microsoft.com/en-us/library/windows/desktop/aa372048(v=vs.85).aspx

in a Win32 Dll with a standard required entrypoint signature. Managed code custom actions are typically implemented using a shim C++ Dll (Visual Studio) that calls into managed code, or C++ that calls out to an external process (WiX DTF). If you are using Visual Studio or WiX both offer support for managed code custom actions.

Having said that, what does your code do that it is required to be a direct call? Running an external executable is supported, whether managed code or not. The executable can call into the class libraries.

It's often useful to describe your ultimate goal. In effect you have decided that the solution to a problem is to edit the MSI, but there's no description of that actual problem. It appears that you want to modify an existing MSI to call code, but you don't want to rebuild it with the available tools.