1
votes

I have completed a WiX 3.9 project, with one hiccup...

It is able to: -- skip the EULA -- ask the user for the database string -- save it in a RegKey -- install files in the inetpub\wwwroot folder (defined by the client) -- creates an AppPool -- creates an IIS -- creates a database -- runs a script to remove the database, if it already exists -- runs a script to create the entire database (tables and contents, necessary user)

However, during uninstall, everything is removed but the database does not drop.

I tested the script to drop the database by running it before the database is created. It works. I cannot get it to run at uninstall.

Here is my wix sql:SqlDatabase tag:

    <!-- - - - - DB/SQL Script - - - - -->
    <sql:SqlDatabase Id="CreateBingoServer" Server="[SERVERNAME]" Database="BingoServer" CreateOnInstall="yes" DropOnUninstall="yes" ContinueOnError="no" >

      <!-- Pre-Drop on Create -->
      <sql:SqlScript Id="PreDrop" BinaryKey="Drop" ExecuteOnInstall="yes" Sequence="1" ContinueOnError="yes" />
      <!-- Create on Install -->
      <sql:SqlScript Id="Script" BinaryKey="Database" ExecuteOnInstall="yes" Sequence="2" ContinueOnError="no" />
      <!-- Drop on Uninstall -->
      <sql:SqlScript Id="Drop" BinaryKey="Drop" ExecuteOnUninstall="yes" Sequence="1" ContinueOnError="no" />
      <!-- -->

    </sql:SqlDatabase>

For Drop, I have tried 'ExecuteOnUninstall' and 'RollbackOnUninstall'.

I have also tried:

      <sql:SqlScript Id="Drop" BinaryKey="Drop" ExecuteOnUninstall="yes" Sequence="1" ContinueOnError="no" SqlDb="CreateBingoServer" />

(outside the sql:SqlDatabase tag) and that does not run. I have changed the 'Sequence' from 1 - 9; no change.

The verbose log shows the database is not found but SERVERNAME = "proper string from RegKey/installer input"

MSI (s) (8C:8C) [11:51:49:620]: APPCOMPAT: looking for appcompat database entry with ProductCode '{Some random GUID}'.

MSI (s) (8C:8C) [11:51:49:620]: APPCOMPAT: no matching ProductCode found in database.

...

MSI (s) (8C:8C) [11:51:49:888]: Component: Database; Installed: Local; Request: Absent; Action: Null

Any ideas?

Thank you, in advance.

1

1 Answers

2
votes

FWIW, I don't recommend running SQL scripts during uninstall. Nothing worse then can't uninstall something because some SQL dependency is throwing an error. Besides, it's user data.... just leave it.

I also don't like the IF EXIST DROP THEN CREATE pattern because you can lose user data.