This example assume that a solution with an application named MyApp
already exists.
Product.wxs
file, valorize the Manufacturer
attribute of the Product
node with HelloWorld
:<Product Id="*" Name="MyApp.Setup" Language="1033" Version="1.0.0.0" Manufacturer="HelloWorld" UpgradeCode="52f2c69b-5901-4d18-bb96-8c1c86cd1a3e">
In the Fragment
node containing the Directory
nodes, wrap the last with a new Directory
:
<Directory Id="ManufacturerFolder" Name="!(bind.property.Manufacturer)">
<Directory Id="INSTALLFOLDER" Name="MyApp.Setup" />
</Directory>
In the ComponentGroup
node, uncomment the commented nodes and remove the TODO
then add a File
node in the Component
:
<File Source="$(var.MyApplication.TargetPath)" />
The Source attribute specifies where to find the file for packaging during the build. Rather than hard-code values for these attributes into our source code, we use the WiX preprocessor variables that are passed to the WiX compiler.
That's it! Now you have a working installer that installs and uninstalls the application.
Full Product.wxs
file:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="MyApp.Setup" Language="1033" Version="1.0.0.0" Manufacturer="HelloWorld" UpgradeCode="52f2c69b-5901-4d18-bb96-8c1c86cd1a3e">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="MyApp.Setup" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="ManufacturerFolder" Name="!(bind.property.Manufacturer)">
<Directory Id="INSTALLFOLDER" Name="MyApp.Setup" />
</Directory>
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="ProductComponent">
<File Source="$(var.MyApp.TargetPath)" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>