Wix工具集:如何创建多个文件夹?

时间:2014-04-07 03:58:46

标签: wix

我是WIX的初学者。我想在主文件夹中创建多个文件夹,但只以一个文件夹结尾。有人可以帮我解决如何创建多个文件夹的问题吗?

                      

    <!-- Step 1: Define the directory structure -->
    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder">
            <Directory Id="APPLICATIONROOTDIRECTORY" Name="TEST">
                <Directory Id="HTML" Name="HTML" />             
            </Directory>
        </Directory>
    </Directory>

    <!-- Step 2: Add files to your installer package -->
    <DirectoryRef Id="APPLICATIONROOTDIRECTORY">
        <Component Id="NewSHU_TM.exe" Guid="3977B09E-B696-471A-9C29-419301EDF6A0">
            <File Id="NewSHU_TM.exe" Source="C:\Program Files\Debug\NewSHU_TM.exe" KeyPath="yes" Checksum="yes"/>
        </Component>
    </DirectoryRef>

    <DirectoryRef Id="HTML">
        <Component Id="exec.html" Guid="61D58D90-F9A3-4649-9113-6AD7B1249DE8">
            <File Id="exec.html" Source="C:\Program Files\Debug\HTML\exec.html" KeyPath="yes" Checksum="yes"/>
            <File Id="exec_001.html" Source="C:\Program Files\Debug\HTML\exec_001.html" KeyPath="no" Checksum="yes"/>
        </Component>
    </DirectoryRef>

    <!-- Step 3: Tell WiX to install the files -->
    <Feature Id="MainApplication" Title="Main Application" Level="1">
        <ComponentRef Id="NewSHU_TM.exe" />
        <ComponentRef Id="exec.html"/>
        <!--<ComponentRef Id="documentation.html" />-->
    </Feature>
</Product>

2 个答案:

答案 0 :(得分:2)

您需要将要安装的目录嵌套到TARGETDIR 中:

 <Directory Id="TARGETDIR" Name="SourceDir">
     <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLDIR" Name="Example">
           <Component Id="ApplicationFiles" Guid="12345678-1234-1234-1234-222222222222">
              <File Id="ApplicationFile1" Source="example.exe"/>
           </Component>
        </Directory>
     </Directory>
  </Directory>

请在此处查看此示例的来源

答案 1 :(得分:1)

您需要关闭每个&#34;目录&#34;元件。请注意结尾&#34; /&gt;&#34;在&#34; TEST&#34;和&#34; HTML&#34;下面的文件夹。

以下内容将创建(假设您正在向这些目录添加文件)两个文件夹位于&#34;示例&#34;下的同一级别。夹: c:\ Program Files(x86)\ Example \ TEST和 c:\ Program Files(x86)\ Example \ HTML

<Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLDIR" Name="Example">
            <Directory Id="ChildFolder1" Name="TEST" /> 
            <Directory Id="ChildFolder2" Name="HTML" /> 
        </Directory>
    </Directory>