<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="SomeApplication" Language="1033" Version="1.0.0.0" Manufacturer="Company" UpgradeCode="4810b5e4-21d8-4a45-b289-eafb10dddc0a">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<Media Id="1" Cabinet="Cab1.cab" EmbedCab="yes" />
<Feature Id="ProductFeature" Title="EvokoInstaller" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
<UIRef Id="WixUI_InstallDir" />
<WixVariable Id="WixUILicenseRtf" Value="LICENSE.rtf" />
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
<InstallExecuteSequence>
<Custom Action="ExtractService" Before="InstallFinalize">NOT Installed</Custom>
</InstallExecuteSequence>
<CustomAction Id="ExtractService" Directory="INSTALLFOLDER" Execute="deferred" ExeCommand="7z e some_service.tar.gz && 7z x some_service.tar" Return="check"/>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="SomeInstaller"/>
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="packages">
<File Source="some_service.tar.gz" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
现在正在将some_service.tar.gz文件复制到安装目录。一旦复制完成,我想要提取该文件。我希望Wix自动完成这个任务。
当我手动执行命令并且命令提示符已经以管理员身份启动时,
7z e some_service.tar.gz && 7z x some_service.tar
命令肯定会执行。如何从Wix中执行它并在提取后删除压缩文件呢?
编辑1:
在@ArkadySitnitsky的评论之后,我添加了建议的代码,现在我无法将some_service.tar.gz文件复制到安装目标位置。
请检查下面的图片:
编辑2:
以下是安装停止并出现错误后事件记录器中的日志。
产品:某产品 - 错误1722。此Windows Installer软件包存在问题。作为设置的一部分运行的程序未能按预期完成。请联系您的支持人员或软件包供应商。操作ExtractService,位置:C:\Program Files (x86)\SomeInstaller\,命令:7z e some_service.tar.gz
编辑3:
当我在命令结尾处添加暂停,像这样:ExeCommand="7z e some_service.tar.gz pause"
,我可以再次安装它。它会复制 .tar.gz 文件并保留其原样。
编辑4:
关于提取完成后压缩文件的删除,我已经尝试过:
<CustomAction Id="ExtractService3"
Directory="INSTALLFOLDER"
Impersonate='no'
Execute="deferred"
ExeCommand="rm liso_service.tar.gz"
Return="check"/>
<CustomAction Id="ExtractService4"
Directory="INSTALLFOLDER"
Impersonate='no'
Execute="deferred"
ExeCommand="rm liso_service.tar"
Return="check"/>
和
<Custom Action="ExtractService3" After="ExtractService2">NOT Deleted</Custom>
<Custom Action="ExtractService4" After="ExtractService2">NOT Deleted</Custom>
但是它又出现了相同的警告弹窗。您能否就此提供建议。
编辑5:
<Custom Action="ExtractService3" After="ExtractService2"></Custom>
<Custom Action="ExtractService4" After="ExtractService2"></Custom>
仍然是相同的结果
编辑6:
rm
命令在我手动尝试时无法工作,并报告错误:
cygintl-2.dll在您的计算机上丢失
我在其他帖子上读到,这是因为OpenSHH没有被正确安装。我必须没有OpenSHH作为依赖项,所以我卸载了它。之后,rm
命令未被识别。因此,我尝试了del
命令(手动)。它可以工作,但只有在以管理员身份运行命令提示符时才能工作。
编辑7:
ExeCommand="del /f /q some_service.tar.gz"
导致相同的弹出窗口。但在安装文件夹中,只有some_service.tar,似乎已删除some_service.tar.gz。当我尝试手动删除del /f /q some_service.tar
时,它会显示
拒绝访问。
编辑8:
我已经尝试删除.tar和tar.gz两个文件。请参见下面:
<CustomAction Id="ExtractService"
Directory="INSTALLFOLDER"
Impersonate='no'
Execute="deferred"
ExeCommand="7z e -y some_service.tar.gz"
Return="check"/>
<CustomAction Id="ExtractService2"
Directory="INSTALLFOLDER"
Impersonate='no'
Execute="deferred"
ExeCommand="7z x -y some_service.tar"
Return="check"/>
<CustomAction Id="ExtractService3"
Directory="INSTALLFOLDER"
Impersonate='no'
Execute="deferred"
ExeCommand="del /f /q some_service.tar.gz"
Return="check"/>
<CustomAction Id="ExtractService4"
Directory="INSTALLFOLDER"
Impersonate='no'
Execute="deferred"
ExeCommand="del /f /q some_service.tar"
Return="check"/>
<InstallExecuteSequence>
<Custom Action="ExtractService" Before="InstallFinalize">NOT Installed</Custom>
<Custom Action="ExtractService2" After="ExtractService">NOT Installed</Custom>
<Custom Action="ExtractService3" After="ExtractService2" ></Custom>
<Custom Action="ExtractService4" After="ExtractService2" ></Custom>
</InstallExecuteSequence>