维克斯 3.5。我的安装项目除了:
- 创建具有值的注册表项;
- 安装两个证书。
可以在没有任何“目录”元素的情况下构建 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 元素的情况下编译我的项目(在我的例子中,Component 元素紧跟在 Binary 元素之后)它会失败并出现以下错误:
“未找到 Component/@Directory 属性;它是必需的。”
更新
感谢严的详细解答。现在我在目录部分的代码片段看起来像(现在更正确了):
<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>