[wix-users] PowerShellWixExtension

Edwin Castro egcastr at gmail.com
Mon Nov 4 00:07:47 PST 2019

I generally discourage database management with the Windows Installer.
There are likely better tools out there. Some of them might be executable
with a Windows Installer custom action. If you really think the Windows
Installer is the tool to use to create/update your database, then have you
considered using the WiX SQL extension,
https://wixtoolset.org/documentation/manual/v3/xsd/sql/ ? For example, you
could use
https://wixtoolset.org/documentation/manual/v3/xsd/sql/sqldatabase.html to
create your database.

If you are talking about  https://github.com/flcdrg/PowerShellWixExtension then
it seems you cannot return any meaningful data. That extension executes
your powershell script files and/or inline scripts in deferred custom
actions. Those custom actions do create a $session variable that you could
use to create properties if and only if your Powershell script was running
immediate. The restriction is one imposed by the Windows Installer engine.
Immediate custom actions can create/modify properties but deferred custom
actions cannot. Deferred custom actions can make system changes but
immediate custom actions cannot. I find
in understanding when various things are executed by the Windows Installer.
The Saw Tooth diagram can be viewed on the wayback machine at
http://flaming.com seems to be down.

In general, with the Windows Installer you need to think declaratively
instead of imperatively. You should make a decision at "immediate-time"
(violet and/or orange regions of the saw tooth diagram) about what the
database name should be and then use that database name in inline scripts
or in an argument to script files which execute at "defer-time" (teal
region of the saw tooth diagram).

The Powershell script file or inline script completes successfully when
there zero non-terminating errors, zero uncaught/unhandled exceptions, and
the exit code reported to the PowerShell host is zero. If there are any
non-terminating errors or any exceptions that are unhandled or the exit
code is set to a non-zero value, then the deferred custom action will fail
and should cause your installation to fail and rollback. So a script
succeeding indicates success. Schedule actions depending on the database
existing after the action that creates it.

Edwin G. Castro

On Sun, Nov 3, 2019 at 9:14 PM Habib Salim via wix-users <
wix-users at lists.wixtoolset.org> wrote:

> Hello,
> I need to create a database with my installer and this Powershell extension
> I stumbled upon today seems like a perfect for the job.
> I want to return a success/failure code and a string containing the
> database name.
> How do I capture these values in a property that I can reference later?
> ____________________________________________________________________
> WiX Toolset Users Mailing List provided by FireGiant
> http://www.firegiant.com/

More information about the wix-users mailing list