如何从jpackage+wix添加快捷方式到Windows应用程序?

pftdvrlh  于 6个月前  发布在  Windows
关注(0)|答案(3)|浏览(102)

我得到了一个脚本(为了简洁起见,只是一个简化的摘录)来构建和打包我的应用程序,但它归结为生成WiX安装程序:

jpackage \
    --type msi \
    --dest "$(cygpath -w "${base[build:dist]}")" \
    --name "${appDisplayName}" \
    --app-version "${version}" \
    --app-image "$(cygpath -w "${base[build:app]}")" \
    --license-file "$(cygpath -w resources/app/legal/LICENSE)" \
    --vendor "${vendor}" \
    --verbose \
    --temp 'W:\_tmp_' \
    --win-shortcut;

字符串
我发现这是关于未解决的引用,特别是对快捷方式图标的引用:...\config\bundle.wxf(10) : error LGHT0094 : Unresolved reference to symbol 'Icon:icon1798580986' in section 'Fragment:'
当我检查生成的WiX XML时,我发现:

<?xml version="1.0" ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
  <Fragment>
  ...
  <DirectoryRef Id="DesktopFolder">
    <Component Win64="yes" Id="cshortcut9906e12cdacb303ebb5e48c888cf6949" Guid="{9906e12c-dacb-303e-bb5e-48c888cf6949}">
      ...
      <Shortcut Id="shortcut9906e12cdacb303ebb5e48c888cf6949" Name="..." WorkingDirectory="INSTALLDIR" Advertise="no" IconIndex="0" Target="[#filed2065cdc42e13
55f8bdbbefc93d540f3]" Icon="icon1798580986"></Shortcut>
    </Component>
  </DirectoryRef>
  ...
</Wix>


确实有这个“icon 1798580986”值,它没有告诉我任何东西,甚至WiX在这里丢失了(在阅读this this https://stackoverflow.com/a/21019152/2024692之后,我检查并确认我确实在WiX bin文件夹中有WixUIExtension.dll)。
当我删除--win-shortcut选项,然后生成MSI安装程序,但不幸的是w/o快捷方式图标在桌面上(该应用程序有它的正确的图标,thou,因为我生成的应用程序图像与--icon开关和--resource-dir指向a.o.应用程序图标).
正如你可能猜到的,这是从Cygwin调用的,所以有时它需要摆弄路径,特别是当调用Windows可执行文件时(因此这些cygpath东西)。
好吧,我无法找到任何建设性的方法如何简单地让我的Java应用程序与jpackage打包(从JDK-14/15 EA没有成功)有漂亮的快捷方式图标安装后.有人知道如何解决这个问题吗?提前感谢.

guicsvcw

guicsvcw1#

使用Gradle插件更容易
你需要设置正确的图标文件路径,并有一个有效的.ico文件。这是我是如何做到的:

jlink {
    options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
    launcher {
        name = 'PDF Decorator'
        jvmArgs = ['-Djdk.gtk.version=2'] // required due to a bug in Java: https://github.com/javafxports/openjdk-jfx/issues/175
    }
    jpackage {
        installerOptions = [
            '--description', project.description,
            '--copyright', 'Copyrigth 2015-2019 WALCZAK.IT'
        ]
        installerType = project.findProperty('installerType') // we will pass this from the command line (example: -PinstallerType=msi)
        if (installerType == 'msi') {
            imageOptions += ['--icon', 'src/main/resources/pdfdecorator/gui/icon.ico']
            installerOptions += [
                '--win-per-user-install', '--win-dir-chooser',
                '--win-menu', '--win-shortcut'
            ]
        }
        if (installerType == 'pkg') {
            imageOptions += ['--icon', 'src/main/resources/pdfdecorator/gui/icon.icns']
        }
        if (installerType in ['deb', 'rpm']) {
            imageOptions += ['--icon', 'src/main/resources/pdfdecorator/gui/icon_256x256.png']
            installerOptions += [
                '--linux-menu-group', 'Office',
                '--linux-shortcut'
            ]
        }
        if (installerType == 'deb') {
            installerOptions += [
                '--linux-deb-maintainer', '[email protected]'
            ]
        }
        if (installerType == 'rpm') {
            installerOptions += [
                '--linux-rpm-license-type', 'GPLv3'
            ]
        }
    }
}

字符串

ef1yzkbh

ef1yzkbh2#

如果在没有--win-shortcut的情况下发生错误94

这实际上可能是一个与jpackage的--app-image参数有关的问题!一个指示符是警告,说明app-image不是由jpackage创建的。
如果你在创建应用镜像时的目标参数看起来像--dest target/app-image,那么你必须在创建安装程序时使用--app-image target/app-image/myapp。使用--app-image target/app-image会导致这个错误。一个小小的疏忽,可能会因为神秘的消息而产生很多令人挠头的问题。
这似乎是因为@Mumrah81给出的原因:
[...]jpackage期望在app-image目录的根目录下找到可执行文件和图标来创建快捷方式。

eiee3dmh

eiee3dmh3#

你刚刚得到了惯例而不是配置所赋予的乐趣
当使用jpackage --app-image--win-shorcut参数时,jpackage期望在app-image目录的根目录下找到可执行文件和图标以创建快捷方式。可执行文件和图标必须与使用--name参数提供的名称相同。
在您的情况下,jpackage期望:

$(cygpath -w "${base[build:app]}")\${appDisplayName}.exe
$(cygpath -w "${base[build:app]}")\${appDisplayName}.ico

字符串
创建快捷方式。

相关问题