WiX 3.5。我的安裝項目除了:不帶目錄的WiX安裝
- 創建一個帶有值的註冊表項;
- 安裝兩個證書。
可以在沒有任何「目錄」元素的情況下構建WiX項目嗎?
這是我的WiX的項目我的XML代碼:
<?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>
其實這個代碼不創建在Program Files文件夾中的任何目錄,但如果我編譯我的項目,而不Directory元素(即組件元素跟在我的情況下的二進制元素)它失敗,並出現以下錯誤:
「組件/ @目錄屬性找不到;它是必需的。
UPDATE
感謝嚴的詳細的解答。現在,在目錄部分我的代碼片段看起來像(現在是更正確的):
<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>
那麼,這個Directory元素的含義是什麼?其實我在安裝時不需要目錄。這只是某種傳統或特定的WiX內部邏輯的問題,它不能在沒有目錄的情況下創建組件? – user808128
Wix只是Windows Installer的聲明性包裝,它必須遵守Windows Installer API規定的規則。 – rene