[bug] MSI updates re-create the desktop shortcut after the user deleted it (NSIS skips it in update mode)
Describe the bug
With the default WiX template, every update re-creates the desktop shortcut, even if the user deleted it. The ApplicationShortcutDesktop component in crates/tauri-bundler/src/bundle/windows/msi/main.wxs has no condition, so the major upgrade installs it again each time.
The NSIS installer already handles this. CreateOrUpdateDesktopShortcut in installer.nsi returns early when $UpdateMode = 1 ("Skip creating shortcut if in update mode"), so NSIS updates leave a deleted shortcut deleted. MSI updates don't.
GitButler users hit this on every update: gitbutlerapp/gitbutler#14722.
Reproduction
- Build any Tauri v2 app with the
msitarget and install it. A desktop shortcut is created. - Delete the desktop shortcut.
- Install a newer version's MSI (or update through
tauri-plugin-updater, which runs the MSI with/passive). - The desktop shortcut is back.
I haven't built an MSI to reproduce this myself; the steps follow from the template and match the GitButler report.
Expected behavior
Same as NSIS: a fresh install creates the shortcut; an update only keeps or refreshes it if it is still there.
Full tauri info output
Not tied to a local setup: the template is unchanged on dev (2e23492ab). GitButler reports it with tauri 2.11 / tauri-build 2.6.1 and the default template.
Additional context
A possible fix in main.wxs, untested: look for the existing shortcut, and skip the component during an upgrade if it isn't there.
<Property Id="DESKTOPSHORTCUTEXISTS">
<DirectorySearch Id="DesktopShortcutSearch" Path="[DesktopFolder]" Depth="0">
<FileSearch Name="{{product_name}}.lnk" />
</DirectorySearch>
</Property>
<Component Id="ApplicationShortcutDesktop" Guid="*">
<Condition>NOT WIX_UPGRADE_DETECTED OR DESKTOPSHORTCUTEXISTS</Condition>
...
</Component>
The Desktop Shortcut registry value under HKCU can't be used for this, since it stays after the user deletes the .lnk. Happy to send a PR if this direction works for you.
I used Claude Code to read the templates and draft this, and reviewed it before posting.
I'm preparing a PR for this. Two things I found while verifying the proposed fix against the WiX 3.14 toolset the bundler uses:
- The
DESKTOPSHORTCUTEXISTSproperty needsSecure="yes". With full UI (double-clicking the MSI),AppSearchruns in the UI sequence only, and the result reaches the elevated execute sequence only if the property is inSecureCustomProperties. Without it the condition would be false on every full-UI upgrade and the shortcut would never be refreshed. - The rest of the proposal compiles cleanly (no new ICE warnings), and the generated sequence is
FindRelatedProducts->AppSearch->CostFinalize->RemoveExistingProducts, so bothWIX_UPGRADE_DETECTEDand the search result are set when the component condition is evaluated.
Note that #16448 rewrites the same component block (moves it under PerMachineDesktopFolder); the change here is small enough to rebase onto whichever lands first.
Opened #16506 with the fix described above (DESKTOPSHORTCUTEXISTS search with Secure="yes", plus the component condition).
Tested on Windows 11 with a minimal Tauri v2 app and /l*v logs: a fresh install creates the shortcut, an upgrade with the shortcut present refreshes it, an upgrade after deleting the shortcut leaves it deleted, and a full-UI upgrade gets the search result on the execute side.