安装时WIX检查文件是否存在

时间:2016-09-06 08:41:17

标签: wix

我的WIX安装程序出现问题。我想检查是否存在特殊文件,是否应该安装,否则不安装。所以目前我正在进行文件搜索:

<Property Id="ARTELABFILEEXISTS">
  <DirectorySearch Id="ArteLabCheckFileDir" Path="$(var.SimuarteaccessPath)" Depth="0">
    <FileSearch Id="CheckFile" Name="Simuarte.dll"/>
  </DirectorySearch>
</Property>

如果不存在,则将功能级别设置为null:

<Feature Id="ArteLab" Title="ArteLab" Level="1">
  <ComponentRef Id="simuartelab"/>
  <Condition Level="0">NOT ARTELABFILEEXISTS</Condition>
</Feature>

但我的组件必须如何?

<Component Id="simuartelab" Directory="TestBedSimulatorDir" KeyPath="yes" Guid="DBC7F690-7336-4F76-97F5-FD6FB7A51317" >
  <File Id="simuarteaccess" Name="simuarteaccess.dll" Source="$(var.SimuarteaccessPath)simuarteaccess.dll" Vital="no"/>
</Component>

如果我这样做,则会收到错误消息,指出找不到文件“$(var.SimuarteaccessPath)simuarteaccess.dll”。

我已经尝试过了:

<?if ARTELABFILEEXISTS="$(var.SimuarteaccessPath)simuarteaccess.dll"?>
  <File Id="simuarteaccess" Name="simuarteaccess.dll" Source="$(var.SimuarteaccessPath)simuarteaccess.dll" Vital="no"/>
<?endif?>

但这也行不通。

编辑1:SimuarteaccessPath定义为:

<?define SimuarteaccessPath="%PUMA%\COBRA\bin\"?>

我非常感谢你的每一次帮助!

亨德里克

1 个答案:

答案 0 :(得分:1)

正如Tom Blodget在评论中提到的,我混淆了WiX和Windows Installer的概念。

如果要在安装过程中检查文件是否存在,则必须使用“自定义操作”进行检查。

相关问题