Wix 运行 命令行摘自 .tar.gz
Wix run command line extract from .tar.gz
我在下面设置了 Wix。
<?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
当我手动执行并且命令提示符被 tar 设置为管理员时肯定会执行此操作。
如何从 Wix 执行它并在解压缩后删除压缩文件。
编辑 1:
在@ArkadySitnitsky 发表评论后,我添加了建议的代码,现在我无法将 some_service.tar.gz 文件复制到安装目标。
请检查图像:
编辑 2:
这是安装因错误而停止后来自事件记录器的日志。
Product: SomeProduct -- Error 1722. There is a problem with this Windows >Installer package. A program run as part of the setup did not
finish as expected. Contact your support personnel or package vendor.
Action ExtractService, location: C:\Program Files
(x86)\SomeInstaller\, command: 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 is missing from your computer
我在其他 post 上读到,这是因为 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
时,它显示
Access is denied.
编辑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>
我有 运行 代码,您应该像这样使用自定义操作:
<CustomAction Id="ExtractService"
Directory="INSTALLFOLDER"
Impersonate='no'
Execute="deferred"
ExeCommand=""[INSTALLFOLDER]7za.exe" e -y cheeseburger.7z"
Return="check"/>
<CustomAction Id="ExtractService2"
Directory="INSTALLFOLDER"
Impersonate='no'
Execute="deferred"
ExeCommand=""[INSTALLFOLDER]7za.exe" x -y cheeseburger.7z"
Return="check"/>
复制此自定义操作并根据需要设置 exe 命令。
还要为每个操作自定义操作,不要使用&&。
只需复制上面的自定义操作,提供不同的 id 名称并将其添加到序列中。
<InstallExecuteSequence>
<Custom Action="ExtractService" Before="InstallFinalize">NOT Installed</Custom>
<Custom Action="ExtractService2" After="ExtractService">NOT Installed</Custom>
</InstallExecuteSequence>
希望对您有所帮助
我在下面设置了 Wix。
<?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
当我手动执行并且命令提示符被 tar 设置为管理员时肯定会执行此操作。
如何从 Wix 执行它并在解压缩后删除压缩文件。
编辑 1:
在@ArkadySitnitsky 发表评论后,我添加了建议的代码,现在我无法将 some_service.tar.gz 文件复制到安装目标。
请检查图像:
编辑 2:
这是安装因错误而停止后来自事件记录器的日志。
Product: SomeProduct -- Error 1722. There is a problem with this Windows >Installer package. A program run as part of the setup did not finish as expected. Contact your support personnel or package vendor. Action ExtractService, location: C:\Program Files (x86)\SomeInstaller\, command: 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 is missing from your computer
我在其他 post 上读到,这是因为 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
时,它显示
Access is denied.
编辑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>
我有 运行 代码,您应该像这样使用自定义操作:
<CustomAction Id="ExtractService"
Directory="INSTALLFOLDER"
Impersonate='no'
Execute="deferred"
ExeCommand=""[INSTALLFOLDER]7za.exe" e -y cheeseburger.7z"
Return="check"/>
<CustomAction Id="ExtractService2"
Directory="INSTALLFOLDER"
Impersonate='no'
Execute="deferred"
ExeCommand=""[INSTALLFOLDER]7za.exe" x -y cheeseburger.7z"
Return="check"/>
复制此自定义操作并根据需要设置 exe 命令。
还要为每个操作自定义操作,不要使用&&。 只需复制上面的自定义操作,提供不同的 id 名称并将其添加到序列中。
<InstallExecuteSequence>
<Custom Action="ExtractService" Before="InstallFinalize">NOT Installed</Custom>
<Custom Action="ExtractService2" After="ExtractService">NOT Installed</Custom>
</InstallExecuteSequence>
希望对您有所帮助