我有以下 wix 文件,该文件应该在安装过程中调用自定义操作。自定义操作将创建程序所需的一些文件。由于 Wix 只会删除安装程序安装的文件,因此自定义操作创建的文件将被保留。所以我求助于删除文件由维克斯提供。
我有以下 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配置文件 and 产品代码.txt。应用程序将创建输出.log,输出.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.
我应该如何正确使用删除文件去除剩菜?我提到this但没有帮助。
UPDATE
我通过在组件标记中添加 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:'
。我该如何解决?
您只能使用RemoveFolder
元素来删除空文件夹,所以这没有多大帮助。
如果您有一个在应用程序目录中创建文件的 CustomAction,我建议您不要创建RemoveFile
那些元素。通常,您将在应用程序目录中创建包含一次性数据的子文件夹,并且必须为添加到该目录的每个文件创建删除元素。解决这个问题的懒惰方法是利用删除FolderEx元素。如该页面所述,您必须使用记住属性模式使这项工作成功。
以下是如何实现这两种技术的示例:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Fragment>
<ComponentGroup Id="CommonFiles" Directory="INSTALLFOLDER">
<Component Id="SomeDLL" Guid="PUT-GUID-HERE">
<File Source="C:\boost_1_55_0_dyn\stage\lib\boost_atomic-vc100-mt-1_55.dll" />
<util:RemoveFolderEx Id="RemoveAdditionalFiles" On="uninstall" Property="REMOVAL"/>
</Component>
<Component>
<RegistryValue Root="HKCU" Key="SOFTWARE\YOURCOMPANY\YOURPRODUCT" Name="CompleteRemoval" Value="[INSTALLFOLDER]" Type="string"/>
<RemoveFolder Id="Cleanup" On="uninstall"/>
</Component>
</ComponentGroup>
<Property Id="REMOVAL">
<RegistrySearch Id="RemovalProperty" Root="HKCU" Key="SOFTWARE\YOURCOMPANY\YOURPRODUCT" Name="CompleteRemoval" Type="raw" />
</Property>
<CustomAction Id='SaveCmdLineValue' Property='REMOVAL_CMD'
Value='[REMOVAL]' Execute='firstSequence' />
<CustomAction Id='SetFromCmdLineValue' Property='REMOVAL'
Value='[REMOVAL_CMD]' Execute='firstSequence' />
<InstallUISequence>
<Custom Action='SaveCmdLineValue' Before='AppSearch' />
<Custom Action='SetFromCmdLineValue' After='AppSearch'>REMOVAL_CMD</Custom>
</InstallUISequence>
<InstallExecuteSequence>
<Custom Action='SaveCmdLineValue' Before='AppSearch' />
<Custom Action='SetFromCmdLineValue' After='AppSearch'>REMOVAL_CMD</Custom>
</InstallExecuteSequence>
</Fragment>
</Wix>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)