Files
cursor-lang/Packaging/Installer/Package.wxs
T
alex 1540be3b79
Release / release (push) Failing after 4m3s
fix wix installer bug (#8)
Reviewed-on: #8
Co-authored-by: Aleksandr Neychev <alexnejchev73@gmail.com>
2026-08-13 22:02:29 +00:00

153 lines
7.4 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!--
The installer for handing the application round outside the Store.
The Store gets an MSIX and signs it itself; this one nobody signs, so Windows
warns about an unknown publisher and the user has to insist. That is the price
of an unsigned build, and short of a certificate from a trusted authority there
is no way round it.
Built by build-installer.ps1 — it publishes both halves of the application and
passes the version, the architecture and the folders in as preprocessor
variables.
-->
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui"
xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
<Package
Name="CursorLang"
Manufacturer="Aleksandr Neichev"
Version="$(var.Version)"
UpgradeCode="B7E4C9A2-5D31-4F86-9E27-3A1C8B0D6F45"
Compressed="yes"
Scope="perUser">
<!--
Installing for the current user alone asks for no administrator rights,
and so for no consent dialog either. The application needs nothing
beyond the user's own account, and one awkward question the less is
worth more here than a copy shared by everyone who signs in.
MSI was designed around installing for the whole machine, and its
validation rules still say so: the ICE checks this trips over are
turned off in the project file, not answered.
-->
<!--
Everything goes inside the .msi. Left to itself WiX puts the cabinet
beside the file, and an installer that has to travel with a second
file next to it is no use to anyone it is sent to
-->
<MediaTemplate EmbedCab="yes" CompressionLevel="high" />
<MajorUpgrade DowngradeErrorMessage="A newer version of CursorLang is already installed." />
<!--
Both halves may be running, and both hold on to files in the install
folder. Named here, they are asked to close instead of the install
failing halfway through on a file it cannot replace
-->
<util:CloseApplication Id="CloseAgent" Target="CursorLang.exe"
CloseMessage="yes" RebootPrompt="no" />
<util:CloseApplication Id="CloseSettings" Target="CursorLang.Settings.exe"
CloseMessage="yes" RebootPrompt="no" />
<Icon Id="CursorLangIcon" SourceFile="$(var.IconFile)" />
<Property Id="ARPPRODUCTICON" Value="CursorLangIcon" />
<Property Id="ARPNOREPAIR" Value="1" />
<!-- Only the folder is asked about: everything here is installed, always -->
<ui:WixUI Id="WixUI_InstallDir" InstallDirectory="INSTALLFOLDER" />
<WixVariable Id="WixUILicenseRtf" Value="$(var.LicenseFile)" />
<StandardDirectory Id="LocalAppDataFolder">
<Directory Id="ProgramsFolder" Name="Programs">
<Directory Id="INSTALLFOLDER" Name="CursorLang" />
</Directory>
</StandardDirectory>
<StandardDirectory Id="ProgramMenuFolder">
<Directory Id="ShortcutFolder" Name="CursorLang" />
</StandardDirectory>
<Feature Id="Main" Title="CursorLang" Level="1">
<ComponentGroupRef Id="Payload" />
<ComponentRef Id="StartMenuShortcut" />
</Feature>
<!--
The whole published folder: two executables, the libraries and the
runtime. Listing them one by one would mean rewriting this file every
time the runtime changes shape
-->
<ComponentGroup Id="Payload" Directory="INSTALLFOLDER">
<Files Include="$(var.PayloadDir)\**" />
</ComponentGroup>
<!--
The shortcut starts the agent — the half that lives in the tray and
shows the layout. The settings window opens from its menu, so it needs
no shortcut of its own.
The key path is a registry value rather than the shortcut file: for
anything installed into the user's profile Windows Installer wants it
that way, and a shortcut cannot serve as one
-->
<Component Id="StartMenuShortcut" Directory="ShortcutFolder" Guid="D4A81C36-7E52-4B19-A0F3-6C2E9D5B8471">
<Shortcut Id="CursorLangShortcut"
Name="CursorLang"
Description="Shows the keyboard layout at the cursor"
Target="[INSTALLFOLDER]CursorLang.exe"
WorkingDirectory="INSTALLFOLDER" />
<RemoveFolder Id="RemoveShortcutFolder" Directory="ShortcutFolder" On="uninstall" />
<RegistryValue Root="HKCU" Key="Software\CursorLang" Name="Shortcut"
Type="integer" Value="1" KeyPath="yes" />
</Component>
<!--
The startup entry is written by the application itself, when startup is
switched on in its settings, and has to go when the application does:
left behind, it would point at an executable that is gone and Windows
would go on listing it in the startup list for good.
RemoveRegistryValue would have been the obvious way to say that, but it
means the opposite of what it sounds like — it wipes the value as the
product is installed, which would quietly switch startup off for anyone
who had turned it on and then upgraded. Hence reg.exe on the way out.
UPGRADINGPRODUCTCODE tells an uninstall apart from the removal of the
old version during an upgrade: the second one has to leave the entry
alone, or upgrading would cost the user their startup setting anyway.
-->
<CustomAction Id="ForgetStartup" Directory="INSTALLFOLDER" Execute="deferred"
Impersonate="yes" Return="ignore"
ExeCommand="&quot;[SystemFolder]reg.exe&quot; delete &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Run&quot; /v CursorLang /f" />
<CustomAction Id="ForgetStartupApproval" Directory="INSTALLFOLDER" Execute="deferred"
Impersonate="yes" Return="ignore"
ExeCommand="&quot;[SystemFolder]reg.exe&quot; delete &quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run&quot; /v CursorLang /f" />
<InstallExecuteSequence>
<Custom Action="ForgetStartup" Before="RemoveFiles"
Condition="REMOVE=&quot;ALL&quot; AND NOT UPGRADINGPRODUCTCODE" />
<Custom Action="ForgetStartupApproval" After="ForgetStartup"
Condition="REMOVE=&quot;ALL&quot; AND NOT UPGRADINGPRODUCTCODE" />
</InstallExecuteSequence>
<SetProperty Id="WixShellExecTarget" Value="[INSTALLFOLDER]CursorLang.exe"
After="CostFinalize" Sequence="ui" />
<CustomAction Id="LaunchApplication" BinaryRef="Wix4UtilCA_$(sys.BUILDARCHSHORT)"
DllEntry="WixShellExec" Impersonate="yes" Return="ignore" />
<UI>
<Publish Dialog="ExitDialog" Control="Finish" Event="DoAction" Value="LaunchApplication"
Condition="WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed" />
</UI>
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Start CursorLang" />
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOX" Value="1" />
</Package>
</Wix>