From a9ec90d539fdbb5786692629275b1a89bfd7aec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Erik=20R=C3=ADos=20Hern=C3=A1ndez?= Date: Fri, 10 Sep 2021 19:53:35 -0500 Subject: [PATCH] fix(msi): fix broken shortcut icon when using msi target, adding msi option `iconId` (#6247) --- .changeset/tiny-dolls-smoke.md | 5 +++++ packages/app-builder-lib/src/options/MsiOptions.ts | 5 +++++ packages/app-builder-lib/src/targets/MsiTarget.ts | 7 +++++-- packages/app-builder-lib/templates/msi/template.xml | 4 ++-- 4 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 .changeset/tiny-dolls-smoke.md diff --git a/.changeset/tiny-dolls-smoke.md b/.changeset/tiny-dolls-smoke.md new file mode 100644 index 00000000000..2a1132aa7ab --- /dev/null +++ b/.changeset/tiny-dolls-smoke.md @@ -0,0 +1,5 @@ +--- +"app-builder-lib": patch +--- + +fix (msi): broken shortcut icon for desktop and startup entry (#5965) diff --git a/packages/app-builder-lib/src/options/MsiOptions.ts b/packages/app-builder-lib/src/options/MsiOptions.ts index 28d6da3d9d5..4132ebdb6c1 100644 --- a/packages/app-builder-lib/src/options/MsiOptions.ts +++ b/packages/app-builder-lib/src/options/MsiOptions.ts @@ -23,4 +23,9 @@ export interface MsiOptions extends CommonWindowsInstallerConfiguration, TargetS * Any additional arguments to be passed to the WiX installer compiler, such as `["-ext", "WixUtilExtension"]` */ readonly additionalWixArgs?: Array | null + + /** + * The [shortcut iconId](https://wixtoolset.org/documentation/manual/v4/reference/wxs/shortcut/). Optional, by default generated using app file name. + */ + readonly iconId?: string } diff --git a/packages/app-builder-lib/src/targets/MsiTarget.ts b/packages/app-builder-lib/src/targets/MsiTarget.ts index 73fff1679fa..8624d95e13d 100644 --- a/packages/app-builder-lib/src/targets/MsiTarget.ts +++ b/packages/app-builder-lib/src/targets/MsiTarget.ts @@ -156,11 +156,13 @@ export default class MsiTarget extends Target { const compression = this.packager.compression const options = this.options const iconPath = await this.packager.getIconPath() + const iconId = `${appInfo.productFilename}Icon.exe`.replace(/\s/g, "") return (await projectTemplate.value)({ ...commonOptions, isCreateDesktopShortcut: commonOptions.isCreateDesktopShortcut !== DesktopShortcutCreationPolicy.NEVER, isRunAfterFinish: options.runAfterFinish !== false, iconPath: iconPath == null ? null : this.vm.toVmFile(iconPath), + iconId: iconId, compressionLevel: compression === "store" ? "none" : "high", version: appInfo.getVersionInWeirdWindowsForm(), productName: appInfo.productName, @@ -221,8 +223,9 @@ export default class MsiTarget extends Target { if (isMainExecutable && (isCreateDesktopShortcut || commonOptions.isCreateStartMenuShortcut)) { result += `>\n` const shortcutName = commonOptions.shortcutName + const iconId = `${appInfo.productFilename}Icon.exe`.replace(/\s/g, "") if (isCreateDesktopShortcut) { - result += `${fileSpace} \n` + result += `${fileSpace} \n` } const hasMenuCategory = commonOptions.menuCategory != null @@ -231,7 +234,7 @@ export default class MsiTarget extends Target { if (hasMenuCategory) { dirs.push(``) } - result += `${fileSpace} \n` + result += `${fileSpace} \n` result += `${fileSpace} \n` result += `${fileSpace} \n` } diff --git a/packages/app-builder-lib/templates/msi/template.xml b/packages/app-builder-lib/templates/msi/template.xml index aae73d84e8e..a21e9853310 100644 --- a/packages/app-builder-lib/templates/msi/template.xml +++ b/packages/app-builder-lib/templates/msi/template.xml @@ -20,8 +20,8 @@ {{ if (iconPath) { }} - - + + {{ } -}} {{ if (isAssisted || isRunAfterFinish) { }}