在使用 WixV4 安装之前运行 PowerShell 脚本

问题描述 投票:0回答:1

我正在尝试使用 Wix 安装程序脚本执行自定义操作,但 v4 的文档有点糟糕,我在任何地方都找不到有效的示例。所有适用于 V3 的代码都不适用于 v4,我无法在任何地方找到如何执行此操作,有人可以提供一个工作示例吗?我想在安装过程开始之前运行自定义 powershell 脚本来执行自身。

尝试生成日志文件,但没有任何帮助 https://github.com/damienbod/WiXPowerShellExample/blob/master/SetupWithPowerShellScripts/Product.wxs——不起作用

https://github.com/wixtoolset/wix/blob/f18d7e628361cd3f2ff14dd3326cbeea68df004f/src/wix/WixToolset.Core/BindFileWithPath.cs没有任何地方解释如何使用这个插件

找到已更改为binaryref 的binarykey 一直是一个挑战...

从 WiX 安装程序运行 PowerShell 脚本也不起作用,因为语法发生了很大变化

    <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
     xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui"
     xmlns:powershell="http://wixtoolset.org/schemas/v4/wxs/powershell">

    
    
    <?if $(var.Platform)=x64 ?>
    <?define ProductCode = "{0F7564E3-56A2-447C-BDA1-8A0D38A0DD5E}"?>
    <?else?>
    <?define ProductCode = "{B304F287-8D2A-4233-8F47-D2D3FD8B07C7}"?>
    <?endif?>
    
    <?define UpgradeCode = "{1E6CD331-2C24-468D-AB2A-6CC0A40B8909}"?>

    <?define BuildVersion = 1.2.3.4?>   
    
  <Package Name="!(loc.ProductName_$(var.Platform))"
           Manufacturer="!(loc.Company)"
           Version="$(var.BuildVersion)"
           UpgradeCode="$(var.UpgradeCode)">


            <SetProperty Id="Dzonson"
            Before ="Dzonson"
            Sequence="execute"
            Value="&quot;[POWERSHELLEXE]&quot; -Version 3.0 -NoProfile -NonInteractive -InputFormat None -ExecutionPolicy Bypass -Command &quot;&amp; '[#djole.ps1]' ; exit $$($Error.Count)&quot;" />

        <CustomAction Id="Dzonson" BinaryRef="Wix4UtilCA_$(sys.BUILDARCHSHORT)" DllEntry="WixShellExec" Execute="deferred" Return="check" Impersonate="no" />

        <InstallExecuteSequence>
            <Custom Action="Dzonson" Before="InstallFiles"></Custom>
        </InstallExecuteSequence>


      

    

       
      
      
    <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" />

      <Icon Id="Icon.ico" SourceFile="$(var.ConsoleApp1.ProjectDir)\app.ico"/>
      <Property Id="ARPPRODUCTICON" Value="Icon.ico"></Property>
      <Property Id="APPURLINFOABOUT" Value="https://e-smartsys.com/"></Property>

      <ui:WixUI
          Id="WixUI_InstallDir1"
          InstallDirectory="INSTALLFOLDER"
          />
      <WixVariable
       Id="WixUILicenseRtf"
       Value="bpl.rtf"
        />
      <WixVariable Id="WixUIDialogBmp" Value="$(var.ProjectDir)/Assets/Background.bmp"/>
      


              <Feature Id="Main">
        
        
      <ComponentGroupRef Id="ExampleComponents" />
    </Feature>
  </Package>
installation package wix windows-installer wix4
1个回答
0
投票

有两件事:

  1. 不要使用 WixShellExec 运行 PowerShell。只需使用标准 Exe CustomAction 即可。 ShellEx 用于通过 explorer.exe 启动目标,例如打开 HTML 文件(在默认浏览器中)。这是针对非常具体的情况。

  2. 您在 InstallFiles 之前安排了操作,但您使用

    [#djole.ps1]
    引用脚本的安装位置。您的 PowerShell 执行可能会失败,因为该文件还不存在。

如果您想通过示例学习,请查看我的每周节目部署道场

© www.soinside.com 2019 - 2024. All rights reserved.