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

4
我是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个回答

3

您需要将要安装的目录嵌套在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>

这个例子的源代码请看这里:


这是一个关于如何使用MSI安装程序创建应用程序安装包的快速介绍。点击上面的链接查看更多信息。

1
你需要关闭每个“Directory”元素。请注意下面的“TEST”和“HTML”文件夹中的结尾“/>”。 以下内容将在“Example”文件夹下创建两个文件夹(如果您要向这些文件夹添加文件): 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>


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接