【问题标题】:Wix run command line extract from .tar.gzWix 从 .tar.gz 运行命令行提取
【发布时间】:2016-04-27 21:52:34
【问题描述】:

我在下面有 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 自动完成。

Command 7z e some_service.tar.gz &amp;&amp; 7z x some_service.tar 在我手动执行并且命令提示符以管理员身份启动时肯定会执行此操作。

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

编辑1:

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

请查看图片:

编辑2:

这是安装因错误停止后来自事件记录器的日志。

产品:SomeProduct -- 错误 1722。此 Windows >Installer 程序包存在问题。作为设置的一部分运行的程序没有 按预期完成。请联系您的支持人员或软件包供应商。 操作 ExtractService,位置:C:\Program Files (x86)\SomeInstaller\,命令:7z e some_service.tar.gz

EDIT3:

当我在命令末尾添加暂停时 像这样:ExeCommand="7z e some_service.tar.gz pause" 我又可以安装它了。它会复制 .tar.gz 并保持原样。

EDIT4:

关于提取完成后的压缩文件删除我试过了:

<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

我在其他帖子上读到这是因为 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 它说

访问被拒绝。

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>

【问题讨论】:

  • 您是否尝试使用 Execute="deferred" 运行自定义操作?
  • @ArkadySitnitsky 我刚刚尝试过,同样的事情发生了。什么都没有。
  • 您的自定义操作未计划,请尝试添加:未安装
  • 其实我根本无法安装。它在中间停止,并带有一个有效的弹出窗口。请检查问题中的弹出图像。
  • 太好了,这意味着您的自定义操作已运行。现在尝试延迟选项,如果不成功,添加有关错误的日志行

标签: command-line wix tar gzip


【解决方案1】:

我已经运行了代码,你应该像这样使用自定义操作:

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

希望对你有帮助

【讨论】:

  • 请检查我上次关于删除压缩文件的编辑。
  • 您需要删除条件“未删除”。
  • 检查手动删除是否有效,如果无效则检查日志。您也可以使用 orca 打开 msi 并检查自定义操作表...
  • 尝试在安装程序中使用 del 命令,同时使用 /F /Q 强制并且不要提示是/否...
  • ExeCommand="del /f /q some_service.tar.gz" 结果与相同的弹出窗口。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-10-11
  • 1970-01-01
  • 2018-01-30
  • 1970-01-01
  • 2013-05-10
相关资源
最近更新 更多