WiX 3.5. My installation project does nothing except:
- creates a registry key with value;
- installs two certificates.
Can the WiX project be constructed without any “Directory” elements?
This is my XML code in my WiX project:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension">
<Product
Id="GUID"
Name="SetupProject1" Language="1033" Version="1.0.0.0"
Manufacturer="SetupProject1" UpgradeCode="GUID">
<Package InstallerVersion="200" Compressed="yes" Languages="1033" SummaryCodepage="1252" />
<Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
<Binary Id="testRootCABinaryStream"
SourceFile="D:\testRootCA.cer" />
<Binary Id="testSigningBinaryStream"
SourceFile="D:\testSigning.cer" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLLOCATION" Name="SetupProject1">
<Component Id="RegistrySetting" Guid="GUID">
<iis:Certificate Id="testRootCA"
BinaryKey="testRootCABinaryStream"
Name="Test Root CA Certificate"
Overwrite="yes"
Request="no"
StoreLocation="localMachine"
StoreName="root"/>
<iis:Certificate Id="testSigning"
BinaryKey="testSigningBinaryStream"
Name="Test Signing Certificate"
Overwrite="yes"
Request="no"
StoreLocation="localMachine"
StoreName="trustedPublisher"/>
<RegistryValue Root="HKLM" Key="Software\Microsoft\Silverlight"
Name="AllowElevatedTrustAppsInBrowser"
Type="integer" Value="00000001" KeyPath="yes" />
</Component>
</Directory>
</Directory>
</Directory>
<Feature Id="Complete" Title="SetupProject1" Level="1">
<ComponentRef Id="RegistrySetting" />
<ComponentGroupRef Id="Product.Generated" />
</Feature>
</Product>
</Wix>
Actually this code doesn’t create any directory in the Program Files folder, but if I compile my project without Directory element (the Component element immediately follows the Binary element in my case) it fails with the following error:
“The Component/@Directory attribute was not found; it is required.”
UPDATE
Thanks to Yan for detailed answer. Now my code snippet in directory part looks like (now it is more correct):
<Directory Id="TARGETDIR" Name="SourceDir" />
<DirectoryRef Id="TARGETDIR">
<Component Id="CompleteInstallation" Guid="Guid">
<iis:Certificate Id="testRootCA"
BinaryKey="testRootCABinaryStream"
Name="Test Root CA Certificate"
Overwrite="yes"
Request="no"
StoreLocation="localMachine"
StoreName="root"/>
<iis:Certificate Id="testSigning"
BinaryKey="testSigningBinaryStream"
Name="Test Signing Certificate"
Overwrite="yes"
Request="no"
StoreLocation="localMachine"
StoreName="trustedPublisher"/>
<RemoveFolder Id="ProgramMenuDir" On="uninstall"/>
<RegistryKey Root="HKLM" Key="Software\Microsoft\Silverlight">
<RegistryValue Name="AllowElevatedTrustAppsInBrowser"
Type="integer" Value="00000001" KeyPath="yes" />
</RegistryKey>
</Component>
</DirectoryRef>
The roots of this behavior goes down to the Windows Installer architecture. As you know, WiX is a set of tools to create Windows Installer packages, that is, it has to reflect the key concepts of this technology to some degree, hiding the most strange and ridiculous stuff behind the syntax sugar. And it does this job amazingly well, being improved from version to version!
Each Windows Installer package must contain a
Directorytable. From MSDN:The corresponding WiX element is:
So, it must be in your WiX authoring. In case you don’t plan to have any directories/files in your installation, you can place the components right under this root
Directoryelement.