1

我在 SO 和 Google 上搜索了一段时间,但没有找到相关问题。所以希望这个问题不是重复的。

对于我的一个客户,我正在使用 WiX 创建安装程序工件。一些文件被安装到

[WindowsVolume]\tool\scripts. 

只要我手动将这些文件添加到相应的 WiX 片段中就可以了。由于这个组件的文件最近经常被移动和删除,我决定通过 subversion 的 heat.exe 获取它们。我面临的一个问题是,heat 的 -ag 开关拒绝在 [WindowsVolume] 上工作——我猜是因为只要组件目录的路径保持不变, -ag 就会使 GUID 保持静态。因此,我使用 -gg 在每次热运行期间生成新的 GUID。测试人员现在报告说文件没有被替换,并且有时根本没有创建文件夹。

通过设置 -ag 开关使用自动生成的 GUID,我收到以下错误消息:

C:\checkouts\project\Setup\tool.fragment.wxs(41,0): error LGHT0231: 
The component 'cmpF69984FE7B4A36DD402E57B30E416ACB' has a key file with path 
'TARGETDIR\indexes\arbitrary.file'.  Since this path is not rooted in one of 
the standard directories (like ProgramFilesFolder), this component does not 
fit the criteria for having an automatically generated guid.  (This error may 
also occur if a path contains a likely standard directory such as nesting a 
directory with name "Common Files" under ProgramFilesFolder.)

在 WiX 中,我有一个主要的 .wxs 定义文件夹、功能和 InstallExecuteSequence。相关文件夹定义为:

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ToolFolder">
    <Directory Id="ToolScriptsFolder" Name="scripts"/>
  </Directory>
</Directory>

<SetDirectory Id="ToolFolder" Value="[WindowsVolume]tool" />

收获的碎片是:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Fragment>
    <DirectoryRef Id="ToolScriptsFolder" />
  </Fragment>

  <Fragment>
    <ComponentGroup Id="CG_ToolScripts">
        <Component Id="cmp2BCA6A75C5C234BEF6FAD9FC41C4B661" 
                   Directory="ToolScriptsFolder" Guid="*">
            <File Id="fil8C1ADEFF76E859B93A97C72A95365E90" 
                  KeyPath="yes" Source="$(var.ToolScripts)\arbitrary.file" />
        </Component>
    </ComponentGroup>
  </Fragment>
</Wix>

知道如何在不将工具\脚本移动到 [ProgramFiles] 的情况下使自动生成的 GUID 工作吗?任何使我免于手动编辑片段的帮助表示赞赏:) 提前致谢!

4

1 回答 1

1

由于我没有找到解决方案,因此我实施了一种解决方法。以防万一将来有人偶然发现类似的问题,这就是诀窍:

  1. 检查注册表中先前安装的脚本目录
  2. 添加RemoveFolderEx自定义操作以删除在先前安装期间写入注册表的目录
  3. 将脚本的目录写入注册表以供下次安装时进一步使用

在代码中它看起来有点像:

<Property Id="LAST_KNOWN_SCRIPTS_LOCATION">
  <RegistrySearch Key="SOFTWARE\vendor\product" Root="HKLM" Type="raw" Id="APPLICATIONFOLDER_REGSEARCH" Name="scriptsLocation" />
</Property>

<SetProperty Id="LAST_KNOWN_SCRIPTS_LOCATION" Value="some\default\directory" Before="AppSearch"><![CDATA[LAST_KNOWN_SCRIPTS_LOCATION]]></SetProperty>

<DirectoryRef Id="ToolScriptsFolder">
  <Component Id="cmp2EB940FB7EFA4691AD58C7AE293A529E" Guid="ED4252705A824BD19441C5574CC99E67">
    <RegistryValue Root="HKLM" Key="SOFTWARE\vendor\product\scriptsLocation" Value="[ToolScriptsFolder]" Type="string" KeyPath="yes"/>
    <util:RemoveFolderEx Id="rmfx_ScriptsFolder" On="both" Property="LAST_KNOWN_SCRIPTS_LOCATION"/>
  </Component>
</DirectoryRef>
于 2014-07-16T16:58:19.710 回答