【问题标题】:wix - The Component element contains an unexpected child element 'Directory'wix - 组件元素包含意外的子元素“目录”
【发布时间】:2013-10-27 12:09:56
【问题描述】:

我正在编写一个 VB 脚本,它递归地进入一个目录并创建一个 WIX XML 文件 我收到错误组件元素包含意外的子元素“目录”。当我尝试编译我的 WIX 时,请有人帮忙。

    <Media Id="1" Cabinet="simple.cab" EmbedCab="yes" />
    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder" Name="PFiles">
            <Directory Id="MSI" Name="MSI">
                <Component Id="first.txt" DiskId="1" Guid="*">
                    <File Id="first.txt" Name="first.txt" Source="C:\Users\xxxx\Desktop\MSI\first.txt" />
                </Component>
                <Component Id="TestProduct" DiskId="1" Guid="*">
                    <Directory Id="TestProduct" Name="TestProduct">
                        <Component Id="snet" DiskId="1" Guid="*">
                            <Directory Id="snet" Name="snet">
                                <Component Id="file1.txt" DiskId="1" Guid="*">
                                    <File Id="file1.txt" Name="file1.txt" Source="C:\Users\xxxx\Desktop\MSI\TestProduct\snet\file1.txt" />
                                </Component>
                                <Component Id="custom" DiskId="1" Guid="*">
                                    <Directory Id="custom" Name="custom">
                                        <Component Id="file2.txt" DiskId="1" Guid="*">
                                            <File Id="file2.txt" Name="file2.txt" Source="C:\Users\xxxx\Desktop\MSI\TestProduct\snet\custom\file2.txt" />
                                        </Component>
                                    </Directory>
                                </Component>
                            </Directory>
                        </Component>
                    </Directory>
                </Component>
            </Directory>
        </Directory>
    </Directory>
    <Feature Id="TestProductFeature" Title="Test" Level="1">
        <ComponentRef Id="first.txt" />
        <ComponentRef Id="TestProduct" />
        <ComponentRef Id="snet" />
        <ComponentRef Id="file1.txt" />
        <ComponentRef Id="custom" />
        <ComponentRef Id="file2.txt" />
    </Feature>
    <UI />
</Product>

【问题讨论】:

  • 我删除了部分 XML,因为它太长了

标签: xml vbscript wix installation windows-installer


【解决方案1】:

WiX 已经有一个程序可以做到这一点,它叫做Heat。如果您只想自己编写一个,则需要了解 Directory 可以是 Directory 的子级,并且 Directory 是 Component 的父级,而不是相反。一个组件只能将文件安装在一个目录中。

您可以使用我的工具IsWiX 拖放文件并查看生成的 XML 以了解它的外观。

【讨论】:

  • " 目录可以是目录的子目录,目录是组件的父目录" 这正是他的代码所显示的。所以有什么问题?我遇到了同样的错误
  • 你删掉了“而不是相反。一个组件只能将文件安装在一个目录中”。这意味着组件不能是目录的父级。 wixtoolset.org/documentation/manual/v3/xsd/wix/component.html
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-05-10
  • 2014-12-05
  • 2011-03-29
  • 2017-05-25
相关资源
最近更新 更多