【发布时间】:2015-02-13 01:21:13
【问题描述】:
我有以下应该在安装期间调用自定义操作的 wix 文件。自定义操作将创建程序所需的一些文件。由于 Wix 只会删除安装程序安装的那些文件,因此自定义操作创建的文件将被保留。所以我求助于Wix提供的RemoveFile。
我有以下 Wix 文件。
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="WixCustomAction" Language="1033" Version="1.0.0.0" Manufacturer="Sarvagya" UpgradeCode="1d77ebdc-2ba2-4b34-b013-7c8a8adcef5b">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes"/>
<Feature Id="ProductFeature" Title="WixCustomAction" Level="1">
<ComponentGroupRef Id="ProductComponents" />
<!--<ComponentGroupRef Id="RemoveLeftOvers" />-->
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="WindowsVolume">
<Directory Id="INSTALLFOLDER" Name="LearningWix" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="SomeDLL">
<File Source="C:\boost_1_55_0_dyn\stage\lib\boost_atomic-vc100-mt-1_55.dll" />
</Component>
<Component Id="RemovingFiles">
<RemoveFile Id="ConfigRemove" Name="lpa.config" On="uninstall"/>
<RemoveFile Id="LogsRemove" Name="*.log" On="uninstall"/>
<RemoveFile Id="ProductCodeRemove" Name="productcode.txt" On="uninstall"/>
</Component>
</ComponentGroup>
<Binary Id="SetupCA" SourceFile="..\LearnCustomAction\bin\Release\LearnCustomAction.CA.dll"/>
<CustomAction Id="FileWrite" Execute="immediate" BinaryKey="SetupCA" DllEntry="WriteFileToDisk" />
<InstallExecuteSequence>
<Custom Action="FileWrite" Before="InstallFinalize"></Custom>
</InstallExecuteSequence>
</Fragment>
自定义操作将创建文件 lpa.config 和 productcode.txt 。应用程序将创建 output.log、output.1.log、...。但是在编译过程中,我得到了以下错误
The Component/@Guid attribute's value '*' is not valid for this component because it does not meet the criteria for having an automatically generated guid. Components using a Directory as a KeyPath or containing ODBCDataSource child elements cannot use an automatically generated guid. Make sure your component doesn't have a Directory as the KeyPath and move any ODBCDataSource child elements to components with explicit component guids.
我应该如何正确使用 RemoveFile 来删除剩菜?我提到了this,但没有任何帮助。
更新
我已通过在组件标签中添加 GUID 来解决此问题。现在在上面的代码中添加RemoveFolder 例如:
<RemoveFolder Id="LeftOverAppsRemove" On="uninstall" Directory="apps"/>
<RemoveFolder Id="LeftOverTempRemove" On="uninstall" Directory="temp"/>
我收到问题Unresolved reference to symbol 'Directory:apps' in section 'Fragment:'。我该如何解决这个问题?
【问题讨论】:
标签: wix windows-installer installation