0

One of the conditions for showing some UI controls in my Setup application is based on whether a file exists.

This check can't be done through custom actions since even the OnBeforeInstall event happens after install, and the dialog I want to alter is shown before that.

If I was using WiX it would be simple as

<Property Id="FILEEXISTS">
   <DirectorySearch Id="CheckFileDir"
                 Path="[CommonAppDataFolder]Manufacturer\Product"
                 Depth="0">
      <FileSearch Id="CheckFile"
              Name="Filename.ext" />
   </DirectorySearch>
</Property>

How to do it without WiX?

Jader Dias
  • 162
  • 1
  • 9

2 Answers2

1

You can put the WiX code into a Merge Module project and then consume it in the Setup Project.

Redemption of Visual Studio Deployment Projects

FWIW, IMO, Setup Projects are just horrible. Microsoft killed it in VS2012 and there are thousands of complains on the user voice site by people who don't know anything about installers to bring them back.

If it was me, since you are doing custom UI work, I'd spend the $2000 on a single copy of InstallShield Professional and adopt merge modules using Windows Installer XML. Sure this can all be done using just WiX but the time saved is worth the $.

Augmenting InstallShield using Windows Installer XML - Certificates

Christopher Painter
  • 54,556
  • 6
  • 63
  • 100
0

You'll need a post build JScript for your MSI file. Or you can do it manually in Orca.

var installer = WScript.CreateObject("WindowsInstaller.Installer");
var filespec = WScript.Arguments(0);
var msiOpenDatabaseModeTransact = 1;
var database = installer.OpenDatabase(filespec, msiOpenDatabaseModeTransact);

Execute("INSERT INTO `AppSearch` (`Property`, `Signature_`) VALUES ('FILEEXISTS', 'CheckFile')");
Execute("INSERT INTO `DrLocator` (`Signature_`, `Parent`) VALUES ('CheckFile', 'CheckFileDir')");
Execute("INSERT INTO `DrLocator` (`Signature_`, `Path`, `Depth`) VALUES ('CheckFileDir', '[CommonAppDataFolder]Manufacturer\\Product', 0)");
Execute("INSERT INTO `Signature` (`Signature`, `FileName`) VALUES ('CheckFile', 'Filename.ext')");

function Execute(sql) {
    view = database.OpenView(sql);
    view.Execute();
    view.Close();
}
Jader Dias
  • 162
  • 1
  • 9