0% found this document useful (0 votes)
19 views

How To Install c# gui apps using wix

The document provides a detailed explanation of a WiX .wxs file used to create an MSI installer for a WPF application, outlining its structure and key elements such as <Product>, <Feature>, and <Directory>. It includes instructions for adding components, shortcuts, and custom actions, as well as tips for common tasks like modifying installation directories and adding license agreements. The document concludes with a reminder to adjust file paths and instructions for building the installer using candle.exe and light.exe.

Uploaded by

Jonah Arthur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

How To Install c# gui apps using wix

The document provides a detailed explanation of a WiX .wxs file used to create an MSI installer for a WPF application, outlining its structure and key elements such as <Product>, <Feature>, and <Directory>. It includes instructions for adding components, shortcuts, and custom actions, as well as tips for common tasks like modifying installation directories and adding license agreements. The document concludes with a reminder to adjust file paths and instructions for building the installer using candle.exe and light.exe.

Uploaded by

Jonah Arthur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Wix Installers

Favorites

Notebook C# Programming

Tags

Last edited time @April 2, 2025 7:45 PM

Archive

Created time @April 2, 2025 7:45 PM

Explanation of the WiX .wxs File


This .wxs file defines an MSI installer for a WPF application. Let's break it down
section by section:

1. Root Element ( <Wix> )


This is the main XML container for the installer and must include the WiX schema
namespace.

2. <Product> Element
Defines the application being installed.

Id="*" : Generates a new GUID for each build.

Name="SetupProject" : The name of the application.

Language="1033" : English (US).

Version="1.0.0.0" : Application version.

Manufacturer="Generalitat de Catalunya" : The developer or company.

UpgradeCode : A GUID for managing upgrades.

Wix Installers 1
Inside <Product> , we have:

<Package> : Specifies installer properties.

InstallScope="perMachine" : Installs for all users.

Compressed="yes" : Embeds all files in the installer.

<MajorUpgrade> : Prevents downgrades.

<MediaTemplate> : Defines media layout for installation files.

3. <Feature> Elements
Defines installable features.

Main Feature ( ProductFeature ):

Installs the core application and shortcuts.

Documentation Feature ( ProductDocumentation ):

Installs extra documentation.

Each <Feature> references <ComponentGroup> elements, which define specific sets of


installed files.

4. User Interface ( UIRef )

<UIRef Id="WixUI_Mondo"/>
<UIRef Id="WixUI_ErrorProgressText"/>
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" />

WixUI_Mondo : Adds a full UI (install location, progress, etc.).

WixUI_ErrorProgressText : Displays error messages.

WIXUI_INSTALLDIR : Defines the install directory.

5. Icon and License

<Icon Id="IconaDePrograma" SourceFile="..\SetupApp\favicon.ico"/>

Wix Installers 2
<WixVariable Id="WixUILicenseRtf" Value="License.rtf"/>

Defines an application icon ( favicon.ico ).

Specifies a license file ( License.rtf ).

6. Custom Actions

<Binary Id="CustomActionDLL" SourceFile="$(var.CustomActionProject.Targe


tDir)CustomActionProject.CA.dll"/>
<CustomAction Id="CA_CustomAction" BinaryKey="CustomActionDLL" DllEntr
y="CustomActionInstallDatabase" Execute="deferred" Impersonate="no" Ret
urn="check"/>
<InstallExecuteSequence>
<Custom Action="CA_CustomAction" After="InstallInitialize"/>
</InstallExecuteSequence>

Runs CustomActionInstallDatabase from CustomActionProject.CA.dll during installation.

7. <Directory> Structure
Defines the install locations.

<Directory Id="TARGETDIR" Name="SourceDir">


<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="MiPrimerSetup">
<Directory Id="DOCFOLDER" Name="docs" />
</Directory>
</Directory>
<Directory Id="ProgramMenuFolder">
<Directory Id="CARPETA_MENU_INICI" Name="MiFirstApplication"/>
</Directory>
<Directory Id="DesktopFolder"/>
</Directory>

Installs files into C:\Program Files\MiPrimerSetup .

Wix Installers 3
Creates a docs subfolder.

Adds a Start Menu folder ( MiFirstApplication ).

Defines DesktopFolder for shortcuts.

8. Installed Files ( ComponentGroup )


Each <Component> represents a file.

<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">


<Component Id="ProductComponent_Executable">
<File Id="FILE_Aplicacio_exe" Source="$(var.SetupApp.TargetDir)SetupA
pp.exe" KeyPath="yes"/>
</Component>
<Component Id="ProductComponent_dll">
<File Id="FILE_Aplicacio_dll" Source="$(var.SetupApp.TargetDir)SetupAp
p.dll" KeyPath="yes"/>
</Component>
<Component Id="ProductComponent_json">
<File Id="FILE_Aplicacio_json" Source="$(var.SetupApp.TargetDir)Setup
App.runtimeconfig.json" KeyPath="yes"/>
</Component>
<Component Id="LlibreriaMatematica_dll">
<File Id="FILE_LlibreriaMatematica_dll" Assembly=".net" Source="$(var.
SetupApp.TargetDir)LlibreriaMatematica.dll" KeyPath="yes"/>
</Component>
</ComponentGroup>

Installs the main SetupApp.exe and related DLLs.

KeyPath="yes" marks the main installation file.

9. Shortcuts

Start Menu Shortcut

Wix Installers 4
<ComponentGroup Id="GC_SHORTCUT_MI" Directory="CARPETA_MENU_INI
CI">
<Component Id="CMP_SHORTCUT_MI" Guid="{4b81c8c7-2721-43ae-b74b
-eced2b7a74b4}">
<Shortcut Id="SHC_MI_EXE"
Icon="IconaDePrograma"
Name="MiFirstApplication"
Description="Shitty application"
Target="[INSTALLFOLDER]SetupApp.exe"/>
<Shortcut Id="SHC_MI_UNINSTALL"
Name="Desintal·lar MiFirstApplication"
Description="Desintal·lar the shitty application"
Target="[System64Folder]msiexec.exe"
Arguments="/x [ProductCode]"/>
<RemoveFolder Id="RemoveMyShortcutsDir" On="uninstall"/>
<RegistryValue Root="HKCU"
Key="Software\IESMila\MiFirstApplication"
Name="installed"
Type="integer"
Value="1"
KeyPath="yes"/>
</Component>
</ComponentGroup>

Adds a shortcut to SetupApp.exe in the Start Menu.

Adds an Uninstall shortcut that calls msiexec.exe /x [ProductCode] .

Desktop Shortcut

<ComponentGroup Id="GC_SHORTCUT_DESK" Directory="DesktopFolder">


<Component Id="CMP_SHORCUT_DESK" Guid="{69ea5bb1-645d-4d89-ae
d4-9af94d1d7502}">
<Shortcut Id="SHC_DESK_EXE"
Icon="IconaDePrograma"
Name="MiFirstApplication"

Wix Installers 5
Description="Shitty Application"
Target="[INSTALLFOLDER]SetupApp.exe"/>
<RegistryValue Root="HKCU"
Key="Software\IESMila\MiFirstApplication"
Name="installedDesktop"
Type="integer"
Value="1"
KeyPath="yes"/>
</Component>
</ComponentGroup>

Adds a desktop shortcut for SetupApp.exe .

How to Do Common Tasks in WiX


1. Add More DLLs to the Installation Folder

Add them inside <ComponentGroup Id="ProductComponents"> :

<Component Id="MyLibrary_dll">
<File Id="FILE_MyLibrary_dll" Source="$(var.SetupApp.TargetDir)MyLib
rary.dll" KeyPath="yes"/>
</Component>

2. Set Custom Icons for Shortcuts

Ensure you have an ICO file and reference it:

<Icon Id="MyAppIcon" SourceFile="myapp.ico"/>

3. Create a Start Menu Shortcut

Already included in <ComponentGroup Id="GC_SHORTCUT_MI"> .

4. Add a License Agreement

The license file must be in RTF format:

Wix Installers 6
<WixVariable Id="WixUILicenseRtf" Value="License.rtf"/>

5. Modify the Installation Directory

Change:

<Directory Id="INSTALLFOLDER" Name="MyApp"/>

This will install in C:\Program Files\MyApp .

Final Thoughts
This sample WiX script covers installation, shortcuts, registry entries, and UI
elements.

You may need to adjust file paths based on your actual WPF project.

To build the installer, use:

candle.exe MySetup.wxs
light.exe -out MySetup.msi MySetup.wixobj

Would you like help setting up WiX 3 in Visual Studio? 🚀

Wix Installers 7

You might also like