命令行 – 来自.tar.gz的Wix run命令行解压缩

我在下面有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可以确定,并且以管理员身份启动命令提示符.

如何从Wix执行它并在提取后删除压缩文件.

EDIT1:

在@ArkadySitnitsky的评论之后我添加了建议的代码,现在我无法将some_service.tar.gz文件复制到安装目的地.

请检查图像:

《命令行 – 来自.tar.gz的Wix run命令行解压缩》

EDIT2:

这是安装后发生错误的事件记录器的日志.

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

EDIT3:

当我在命令结束时添加暂停时
像这样:ExeCommand =“7z e some_service.tar.gz pause”我再次能够安装它.它会复制.tar.gz并保持原样.

EDIT4:

关于提取完成后的compresed文件删除我尝试过:

<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>

但同样,它会产生同样的问题弹出窗口.你能就此提出建议吗?

EDIT5:

 <Custom Action="ExtractService3" After="ExtractService2"></Custom>
  <Custom Action="ExtractService4" After="ExtractService2"></Custom>

结果仍然相同

EDIT6:

当我手动尝试rm命令时它没有工作,它报告错误:

cygintl-2.dll is missing from your computer

我在其他帖子上看到,这是因为OpenSHH没有正确安装.我不能将OpenSHH作为依赖项,因此我将其卸载.之后rm命令无法识别.因此,我尝试了del命令(手动).它可以工作,但只有命令提示符以管理员身份运行.

EDIT7:

ExeCommand =“del / f / q some_service.tar.gz”结果使用相同的弹出窗口.但是在安装文件夹中只有some_service.tar,似乎some_service.tar.gz被删除了.当我尝试手动删除del / f / q some_service.tar时,它说

Access is denied.

EDIT8:

我已经在尝试删除.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="&quot;[INSTALLFOLDER]7za.exe&quot; e -y cheeseburger.7z" 
              Return="check"/>

<CustomAction Id="ExtractService2" 
              Directory="INSTALLFOLDER" 
              Impersonate='no' 
              Execute="deferred" 
              ExeCommand="&quot;[INSTALLFOLDER]7za.exe&quot; 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>

希望它有所帮助

点赞