Windows installer: offer a desktop shortcut (#32) (#184)

The MSI gets a setup wizard (WixUI dialogs, no licence or folder page) with a
Shortcuts page: the Start Menu shortcut as before, plus an opt-in "Create a
desktop shortcut" checkbox bound to DESKTOPSHORTCUT. Silent installs take
DESKTOPSHORTCUT=1. The shortcut goes on the all-users desktop (per-machine
install) in its own component with an HKCU key path (ICE38/43/57), so
uninstall removes it; upgrades read that value back and keep the previous
choice unless DESKTOPSHORTCUT is given.

The build now needs WixToolset.UI.wixext 5.0.2 (release workflow and
package.ps1 updated).

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Valentin Klein
2026-10-10 12:16:13 -04:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 14cffbcbe6
commit b7be0a5fda
5 changed files with 118 additions and 7 deletions
+108 -4
View File
@@ -1,11 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
CADCraft MSI (WiX Toolset v5: `dotnet tool install -g wix`). Built by package.ps1:
CADCraft MSI (WiX Toolset v5: `dotnet tool install -g wix`, plus the WixUI extension:
`wix extension add -g WixToolset.UI.wixext/5.0.2`). Built by package.ps1:
wix build cadcraft.wxs -arch x64 -d Version=1.2.3 -d BinDir=... -d IconPath=... -o out.msi
wix build cadcraft.wxs -arch x64 -ext WixToolset.UI.wixext -d Version=1.2.3 -d BinDir=... -d IconPath=... -o out.msi
Per-machine install into Program Files, a Start Menu shortcut, and CADCraft offered under
"Open with" for .dxf and .dwg drawings (without taking over the user's default app).
Per-machine install into Program Files, a Start Menu shortcut, an optional desktop shortcut, and
CADCraft offered under "Open with" for .dxf and .dwg drawings (without taking over the user's
default app).
Desktop shortcut: the setup wizard asks (unchecked by default). Silent installs leave it out
unless asked: `msiexec /i cadcraft.msi /qn DESKTOPSHORTCUT=1`. Upgrades keep the previous choice
unless DESKTOPSHORTCUT=1 or DESKTOPSHORTCUT=0 is given.
-->
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Package
@@ -33,6 +39,24 @@
<Directory Id="INSTALLFOLDER" Name="CADCraft" />
</StandardDirectory>
<StandardDirectory Id="ProgramMenuFolder" />
<!-- Per-machine (ALLUSERS=1), so this is the all-users (Public) desktop, like the Start Menu above. -->
<StandardDirectory Id="DesktopFolder" />
<!-- "Create a desktop shortcut": the wizard's checkbox sets it to 1 (cleared = unset), and
silent installs pass DESKTOPSHORTCUT=1. Secure, so the elevated install sees the UI choice. -->
<Property Id="DESKTOPSHORTCUT" Secure="yes" />
<!-- The previous install's choice (the shortcut component's HKCU key path, so the installing
user's), so upgrades keep the desktop shortcut without asking again. -->
<Property Id="PREVIOUSDESKTOPSHORTCUT">
<RegistrySearch Id="PreviousDesktopShortcut" Root="HKCU" Key="Software\Learning Machines LLC\CADCraft"
Name="DesktopShortcut" Type="raw" />
</Property>
<!-- Only when DESKTOPSHORTCUT wasn't given; "first" runs it once (in the UI sequence when there
is one), so unticking the box isn't undone by the execute sequence. -->
<SetProperty Id="DESKTOPSHORTCUT" Value="1" After="AppSearch" Sequence="first"
Condition="NOT DESKTOPSHORTCUT AND PREVIOUSDESKTOPSHORTCUT = &quot;1&quot;" />
<UIRef Id="CadcraftUI" />
<Feature Id="Main" Title="CADCraft" Level="1">
<ComponentGroupRef Id="CadcraftFiles" />
@@ -58,6 +82,86 @@
<Component Id="CadcraftCli">
<File Id="CadcraftCliExe" Source="$(var.BinDir)\cadcraft-cli.exe" KeyPath="yes" />
</Component>
<!-- Optional desktop shortcut, removed on uninstall. A non-advertised shortcut needs a registry
key path, and one in a profile folder (DesktopFolder, even though ALLUSERS=1 makes it the
Public desktop) must be under HKCU (ICE38, ICE43, ICE57). -->
<Component Id="DesktopShortcut" Directory="DesktopFolder" Guid="76029CD7-EBDB-420F-AC34-FF0E82A99E32"
Condition="DESKTOPSHORTCUT = &quot;1&quot;">
<Shortcut Id="DesktopShortcut" Name="CADCraft" Description="CADCraft computer-aided design"
Target="[INSTALLFOLDER]cadcraft.exe" WorkingDirectory="INSTALLFOLDER" Icon="CadcraftIcon.ico" IconIndex="0" />
<RegistryValue Root="HKCU" Key="Software\Learning Machines LLC\CADCraft" Name="DesktopShortcut"
Value="1" Type="string" KeyPath="yes" />
</Component>
</ComponentGroup>
</Fragment>
<!--
Setup wizard: WixUI_InstallDir's flow (WiX v5, ext/UI/wixlib/WixUI_InstallDir.wxs) without the
licence and folder pages, plus a Shortcuts page:
install: Welcome > Shortcuts > Ready to install > Progress > Finish
maintenance: Maintenance welcome > Repair/Remove > Ready > Progress > Finish
-->
<Fragment>
<UI Id="CadcraftUI">
<TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
<TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
<TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />
<Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
<DialogRef Id="DiskCostDlg" />
<DialogRef Id="ErrorDlg" />
<DialogRef Id="FatalError" />
<DialogRef Id="FilesInUse" />
<DialogRef Id="MsiRMFilesInUse" />
<DialogRef Id="PrepareDlg" />
<DialogRef Id="ProgressDlg" />
<DialogRef Id="ResumeDlg" />
<DialogRef Id="UserExit" />
<Dialog Id="ShortcutsDlg" Width="370" Height="270" Title="!(loc.InstallDirDlg_Title)">
<Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)" />
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)" />
<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)">
<Publish Event="SpawnDialog" Value="CancelDlg" />
</Control>
<Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes"
Text="Choose where to start [ProductName] from." />
<Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes"
Text="{\WixUI_Font_Title}Shortcuts" />
<Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.InstallDirDlgBannerBitmap)" />
<Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
<Control Id="StartMenuText" Type="Text" X="20" Y="60" Width="330" Height="15" NoPrefix="yes"
Text="[ProductName] will be added to the Start menu." />
<Control Id="DesktopShortcutCheckBox" Type="CheckBox" X="20" Y="85" Width="330" Height="17"
Property="DESKTOPSHORTCUT" CheckBoxValue="1" Text="Create a &amp;desktop shortcut" />
</Dialog>
<Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999" />
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="ShortcutsDlg" Condition="NOT Installed" />
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Condition="Installed AND PATCH" />
<Publish Dialog="ShortcutsDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" />
<Publish Dialog="ShortcutsDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" />
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="ShortcutsDlg" Order="1" Condition="NOT Installed" />
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="2" Condition="Installed AND NOT PATCH" />
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="2" Condition="Installed AND PATCH" />
<Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg" />
<Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog" Value="VerifyReadyDlg" />
<Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg" />
<Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg" />
<!-- No "Change" in Apps & features: there is a single feature. -->
<Property Id="ARPNOMODIFY" Value="1" />
</UI>
<UIRef Id="WixUI_Common" />
</Fragment>
</Wix>
+4 -2
View File
@@ -12,7 +12,9 @@
warning when no signing secrets are set).
Needs: Rust (MSVC toolchain + the target), the Windows SDK (rc.exe, signtool.exe),
and WiX v5: dotnet tool install --global wix --version 5.0.2
and WiX v5 with its UI extension (the setup wizard):
dotnet tool install --global wix --version 5.0.2
wix extension add -g WixToolset.UI.wixext/5.0.2
.EXAMPLE
pwsh packaging/windows/package.ps1 -Arch x64
@@ -93,7 +95,7 @@ Copy-Item (Join-Path $Bin 'cadcraft.exe'), (Join-Path $Bin 'cadcraft-cli.exe') $
# ---- MSI ---------------------------------------------------------------------------------------
$Msi = Join-Path $Dist "cadcraft-$Version-windows-$Arch.msi"
Invoke-Native 'wix build' {
wix build (Join-Path $PSScriptRoot 'cadcraft.wxs') -arch $Arch `
wix build (Join-Path $PSScriptRoot 'cadcraft.wxs') -arch $Arch -ext WixToolset.UI.wixext `
-d "Version=$MsiVersion" -d "BinDir=$Stage" -d "IconPath=$(Join-Path $Root 'assets\app-icon\cadcraft.ico')" `
-o $Msi
}