如何从jpackage+wix向Windows APP添加快捷方式? [英] How to add shortcut to Windows app from jpackage+wix?

查看:63
本文介绍了如何从jpackage+wix向Windows APP添加快捷方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了一个脚本(为简洁起见,只是一个简化的摘录)来构建和打包我的应用程序,但它归结起来就是用以下命令生成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;

失败,错误为:Command [light.exe, (...)] in (...) exited with 94 code。我发现的内容是关于未解析的引用,特别是对快捷方式图标的引用:...configundle.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>

确实有这个"icon1798580986"值,它没有告诉我任何事情,甚至Wix在这里都丢失了(阅读此https://stackoverflow.com/a/21019152/2024692后,我检查并确认我确实有WixUIExtension.dll在Wixbin文件夹中)。

当我删除--win-shortcut选项时,会生成MSI安装程序,但不幸的是桌面上没有快捷方式图标(应用程序有合适的图标,因此,正如我使用--icon开关和--resource-dir指向A.O.生成的应用程序图像一样。应用程序图标)。

正如您可能猜到的,这是从Cygwin调用的,所以有时它需要摆弄路径,特别是在调用Windows可执行文件时(因此这些cygpath内容)。

嗯,我找不到任何有建设性的方法,如何简单地让我的Java应用程序(来自JDK-14/15EA,但都没有成功)打包的jpackage在安装后拥有漂亮的快捷方式图标。有人知道怎么解决这个问题吗?提前谢谢。

推荐答案

使用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', 'office@walczak.it'
            ]
        }
        if (installerType == 'rpm') {
            installerOptions += [
                '--linux-rpm-license-type', 'GPLv3'
            ]
        }
    }
}

这里有一篇文章,介绍如何使用OpenJDK 11和使用OpenJDK 14和jpackage构建仅用于构建安装程序/包的应用程序镜像:https://walczak.it/blog/distributing-javafx-desktop-applications-without-requiring-jvm-using-jlink-and-jpackage

这篇关于如何从jpackage+wix向Windows APP添加快捷方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆