Skip to content

Commit

Permalink
fix(msi): fix broken shortcut icon when using msi target, adding msi …
Browse files Browse the repository at this point in the history
…option `iconId` (#6247)
  • Loading branch information
erikrz committed Sep 11, 2021
1 parent 8bd1f3e commit a9ec90d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/tiny-dolls-smoke.md
@@ -0,0 +1,5 @@
---
"app-builder-lib": patch
---

fix (msi): broken shortcut icon for desktop and startup entry (#5965)
5 changes: 5 additions & 0 deletions packages/app-builder-lib/src/options/MsiOptions.ts
Expand Up @@ -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<string> | null

/**
* The [shortcut iconId](https://wixtoolset.org/documentation/manual/v4/reference/wxs/shortcut/). Optional, by default generated using app file name.
*/
readonly iconId?: string
}
7 changes: 5 additions & 2 deletions packages/app-builder-lib/src/targets/MsiTarget.ts
Expand Up @@ -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,
Expand Down Expand Up @@ -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} <Shortcut Id="desktopShortcut" Directory="DesktopFolder" Name="${shortcutName}" WorkingDirectory="APPLICATIONFOLDER" Advertise="yes" Icon="icon.ico"/>\n`
result += `${fileSpace} <Shortcut Id="desktopShortcut" Directory="DesktopFolder" Name="${shortcutName}" WorkingDirectory="APPLICATIONFOLDER" Advertise="yes" Icon="${iconId}"/>\n`
}

const hasMenuCategory = commonOptions.menuCategory != null
Expand All @@ -231,7 +234,7 @@ export default class MsiTarget extends Target {
if (hasMenuCategory) {
dirs.push(`<Directory Id="${startMenuShortcutDirectoryId}" Name="ProgramMenuFolder:\\${commonOptions.menuCategory}\\"/>`)
}
result += `${fileSpace} <Shortcut Id="startMenuShortcut" Directory="${startMenuShortcutDirectoryId}" Name="${shortcutName}" WorkingDirectory="APPLICATIONFOLDER" Advertise="yes" Icon="icon.ico">\n`
result += `${fileSpace} <Shortcut Id="startMenuShortcut" Directory="${startMenuShortcutDirectoryId}" Name="${shortcutName}" WorkingDirectory="APPLICATIONFOLDER" Advertise="yes" Icon="${iconId}">\n`
result += `${fileSpace} <ShortcutProperty Key="System.AppUserModel.ID" Value="${this.packager.appInfo.id}"/>\n`
result += `${fileSpace} </Shortcut>\n`
}
Expand Down
4 changes: 2 additions & 2 deletions packages/app-builder-lib/templates/msi/template.xml
Expand Up @@ -20,8 +20,8 @@
<Property Id="WixAppFolder" Value="WixPerUserFolder"/>

{{ if (iconPath) { }}
<Icon Id="icon.ico" SourceFile="${iconPath}"/>
<Property Id="ARPPRODUCTICON" Value="icon.ico"/>
<Icon Id="${iconId}" SourceFile="${iconPath}"/>
<Property Id="ARPPRODUCTICON" Value="${iconId}"/>
{{ } -}}

{{ if (isAssisted || isRunAfterFinish) { }}
Expand Down

0 comments on commit a9ec90d

Please sign in to comment.