WiX Property ID或条件声明

时间:2012-01-23 15:56:53

标签: wix

我需要创建一个安装文件来检查注册表中是否有其他软件的版本。目前我正在评论和取消评论单独的安装代码行。如何将以下内容变为条件?

<!--<Property Id="ACADREG" Value="ACAD-A001:409" /> Autocad 2012--> 
<Property Id="ACADREG" Value="ACAD-A004:409" /> <!--Autocad Arch 2012--> 

我还需要获取安装后期的版本。

    <Property Id="ACADROAMDIR">
    <RegistrySearch Id="ROAMROOTDIR" Root="HKCU" Type="raw" Key="Software\Autodesk\AutoCAD\[ACADVER]\[ACADREG]" Name="RoamableRootFolder" />
    </Property>


    <Property Id="ACADDIR">
    <RegistrySearch Id="AcadLocRegistry" Type="raw" Root="HKLM" Key="SOFTWARE\Autodesk\AutoCAD\[ACADVER]\[ACADREG]" Name="AcadLocation" />
    </Property>

wiX有没有办法通过阅读注册表设置[ACADREG]而不是像我上面那样设置它?

2 个答案:

答案 0 :(得分:1)

您可以使用Preprocessor条件:

<?define AutocadSku = "ACAD2012" ?>

<?if $(var.AutocadSku) = "ACAD2012" ?>
  <Property Id="ACADREG" Value="ACAD-A001:409" />
<?else?>
  <Property Id="ACADREG" Value="ACAD-A004:409" />
<?endif ?>

或者甚至更好,最佳做法是搜索两者,所以稍后您可以有条件地检查每个属性的存在或内容:

<Property Id="ACADROAMROOTDIR">
  <RegistrySearch Id="ROAMROOTDIR" Root="HKCU" Type="raw" Key="Software\Autodesk\AutoCAD\R18.2\ACAD-A001:409" Name="RoamableRootFolder" />
</Property>
<Property Id="ACADROAMARCHROOTDIR">
  <RegistrySearch Id="ARCHROAMROOTDIR" Root="HKCU" Type="raw" Key="Software\Autodesk\AutoCAD\R18.2\ACAD-A004:409" Name="RoamableRootFolder" />
</Property>

答案 1 :(得分:0)

如果定义了AutoCAD Arch 2012,您似乎想要重新定义属性,否则请使用Autocad 2012。 我有一个类似的问题,我使用了我在SO question

上找到的解决方案
<Property Id="ACADREG" Value="ACAD-A001:409" /> <!-- Autocad 2012--> 
<Property Id="ACADREG_ARCH" Value="ACAD-A004:409" /> <!--Autocad Arch 2012--> 


<Property Id="ACADROAMDIR">
<RegistrySearch Id="ROAMROOTDIR" Root="HKCU" Type="raw" Key="Software\Autodesk\AutoCAD\[ACADVER]\[ACADREG]" Name="RoamableRootFolder" />
</Property>

<Property Id="ACADROAMDIR_ARCH">
<RegistrySearch Id="ROAMROOTDIR" Root="HKCU" Type="raw" Key="Software\Autodesk\AutoCAD\[ACADVER]\[ACADREG_ARCH]" Name="RoamableRootFolder" />
</Property>

<Property Id="ACADDIR">
<RegistrySearch Id="AcadLocRegistry" Type="raw" Root="HKLM" Key="SOFTWARE\Autodesk\AutoCAD\[ACADVER]\[ACADREG]" Name="AcadLocation" />
</Property>

<Property Id="ACADDIR_ARCH">
<RegistrySearch Id="AcadLocRegistry" Type="raw" Root="HKLM" Key="SOFTWARE\Autodesk\AutoCAD\[ACADVER]\[ACADREG_ARCH]" Name="AcadLocation" />
</Property>

<SetProperty Id="ACADROAMDIR" After="AppSearch" Value="[ACADROAMDIR_ARCH]">
 ACADROAMDIR_ARCH
</SetProperty>

<SetProperty Id="ACADDIR" After="AppSearch" Value="[ACADDIR_ARCH]">
 ACADDIR_ARCH
</SetProperty>

之后,您想要的属性将正确地位于ACADDIR和ACADROAMDIR