在连续交付代理上使用 jpackage 构建 Windows 安装程序

问题描述

我在 CD 代理上运行 jpackage 任务时遇到问题。 我收到以下错误

light.exe : error LGHT0217 : Error executing ICE action 'ICE01'. The most common cause of this kind of ICE failure is an incorrectly registered scripting engine. See http://wixtoolset.org/documentation/error217/ for details and how to solve this problem. The following string format was not expected by the external UI message logger: "The Windows Installer Service Could not be accessed. This can occur if the Windows Installer is not correctly installed. Contact your support personnel for assistance.".

我做了一些研究,基本上问题可以通过以下方式解决

  1. 为代理用户添加管理员权限
  2. env 变量大小的非常大的大小(对于某些人来说,大小大于 32KB 的 env 变量会导致类似的错误
  3. 禁止 ICE 验证

就我而言,这些解决方案中的每一个都无关紧要或有问题。

  1. 我无法在 CD 上使用管理员用户
  2. 环境变量小于 32KB (10KB)
  3. 我找不到使用 jpackage 抑制 ICE 验证的方法 - 我知道可以通过将 -sval 传递给 light.exe 或 wixproj 文件中的 specyfing 属性来完成,但我不知道如何输入 light.exe 参数到 jpackage(如果可能)和传入 --resource-dir 的 wixproj 文件似乎没有做任何更改。

明确地说,它在我的本地环境中运行良好。

所以很可能我的问题可以归结为是否可以从 jpackage 级别抑制 ICE 验证的问题。

我将 badass-runtime-plugin 用于 gradle 并尝试为 javafx + spring boot 应用程序构建安装程序。这是我的 build.gradel 相关部分:

runtime {
    modules = ['java.management','java.naming','java.instrument','java.sql','jdk.unsupported','jdk.security.jgss','java.desktop','java.logging','jdk.jfr','java.xml','java.scripting','jdk.crypto.cryptoki']
    options = ['--strip-debug','--compress','2','--no-header-files','--no-man-pages']
    launcher {
        noConsole = false
    }
    jpackage {
        mainClass = 'org.springframework.boot.loader.JarLauncher'
        imageOptions += ['--icon',"src/main/resources/graphics/icon.ico"]
        imageOptions += ['--win-console']
        installerOptions += ['--resource-dir',"src/main/resources"]
        installerOptions += ['--vendor','XYZ']
        installerOptions += ['--type','msi']
        installerOptions += ['--verbose']
        installerOptions += ['--resource-dir',"src/main/resources/wix"]
        installerOptions += ['--win-per-user-install','--win-dir-chooser','--win-menu','--win-shortcut']
    }
}

解决方法

根据 badass-runtime-plugin's author 的说法,使用 jpackage 很可能无法做到这一点。

然而,我设法想出了一些肮脏的技巧,以某种方式让我实现了我的目标。 我为 jpackage 添加了 tempDir 参数,然后在 gradle 构建失败后,我“手动”使用 -sval 开关对来自 tempDir 的文件运行 light.exe。