How do I use the SourceDir MSI property in WiX?

2019-02-24 19:13发布

Using WiX, how can I detect if a particular file exists in the SourceDir folder?

I have the following WiX fragment designed to determine whether the Adobe Reader installer has been distributed in the same folder as my MSI file, and if so, run it after installation.

<Property Id="ADOBEREADERINSTALLER">
  <DirectorySearch Id="SourceDir" Path="[SourceDir]" Depth="0" AssignToProperty="yes">
    <FileSearch
      Id="AdbeRdr810_en_US.exe"
      Name="AdbeRdr810_en_US.exe"
      MaxDate="2011-03-24T13:18:59" MaxSize="23402288" MaxVersion="1.0.0.92"
      MinDate="2011-03-24T13:18:00" MinSize="23402288" MinVersion="1.0.0.92"
    />
  </DirectorySearch>
</Property>
<Property Id="INSTALLADOBEREADER" Value="1" />

<CustomAction
  Id         ="InstallAdobeReader"
  Property   ="ADOBEREADERINSTALLER"
  ExeCommand =""
  Execute    ="immediate"
  Return     ="asyncNoWait" />

<InstallUISequence>
  <ResolveSource After="CostInitialize"> UPGRADINGPRODUCTCODE OR NOT Installed </ResolveSource>
</InstallUISequence>

<InstallExecuteSequence>
  <Custom Action="InstallAdobeReader" After="InstallFinalize"> (UPGRADINGPRODUCTCODE OR NOT Installed) AND ADOBEREADERINSTALLER AND INSTALLADOBEREADER </Custom>
</InstallExecuteSequence>

It appears that the AppSearch action (which performs the DirectorySearch and FileSearch) must occur before the ResolveSource action (which sets the value of SourceDir.) This leaves me in backwards-about situation.

1条回答
等我变得足够好
2楼-- · 2019-02-24 19:31

A solution is to use a custom action right after ResolveSource instead of a search. This custom action can check if the file exists and save the result in your custom installer property.

To get access to installer properties you can use a win32 DLL or VBScript custom action.

查看更多
登录 后发表回答