Reputation: 521
WiX 3.5. My installation project does nothing except:
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>
Upvotes: 4
Views: 8006
Reputation: 42494
You have to set the Directory attribute your self on the Component element if you put it directly under Product because it is required.
From the doc:
Sets the Directory of the Component. If this element is nested under a Directory element, this value defaults to the value of the parent Directory/@Id.
As it turns-out, in the Windows Installer reference is stated that the Component needs to have a directory_ attribute that points to a record in the directory table, or by a value obtained from an AppSearch. I'm not sure how this will work out if AppSearch is empty.
Upvotes: 2
Reputation: 32270
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 Directory
table. From MSDN:
The Directory table must specify a single root directory with a Directory column value equal to the TARGETDIR property.
The corresponding WiX element is:
<Directory Id="TARGETDIR" Name="SourceDir">
...
</Directory>
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 Directory
element.
Upvotes: 12