【问题标题】:How to create a directory in wix?如何在wix中创建目录?
【发布时间】:2019-02-25 17:36:14
【问题描述】:

我的要求是在 programdata/test/example 中创建一个目录。我怎样才能在 wix 中做到这一点?

【问题讨论】:

    标签: wix installation windows-installer wix3.5


    【解决方案1】:

    这样定义文件夹:

    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="CommonAppDataFolder">
            <Directory Id="TestFolder" Name="test">
                <Directory Id="ExampleFolder" Name="example" />
            </Directory>
        </Directory>
    </Directory>
    

    这里的重要部分是CommonAppDataFolder Id,Windows 安装程序知道它。您可以在Windows Installer Property Reference 中找到已知系统文件夹的完整列表。

    如果您将任何文件安装到该文件夹​​,它将被隐式创建。如果没有,您可以通过安装这样的组件来强制创建它:

    <Component Id="CreateTestFolder" Directory="ExampleFolder" Guid="PUT-RANDOM-GUID-HERE">
        <CreateFolder />
    </Component>
    

    【讨论】:

    • 我在使用它时遇到了这个错误:error CNDL0205: The Directory with Id 'CommonAppDataFolder' is not a valid root directory. (加上更多关于每个产品只有一个根目录的信息)。我做错了什么?
    • @noelicus:在 Windows 安装程序中,顶级父目录必须始终为 TARGETDIR。我将更新我的答案以澄清这一点。
    • @WimCoenen 是否可以在安装 wix 安装程序的过程中复制文件夹/files1..to..files5。
    • @Royal:cmets 不适合提出新问题。只需发布一个新的 stackoverflow 问题。
    • @WimCoenen 我提出了新的 SO 问题,请帮助我stackoverflow.com/questions/27020130/…
    【解决方案2】:

    &lt;Product&gt;下可以输入:

       <DirectoryRef Id="TARGETDIR">
          <Directory Id="CommonAppDataFolder">
            <Directory Id="CommonAppXXXX" Name="test">
              <Directory Id="CommonAppYYYY" Name="example">
                <Component Id="CreateProgramDataZZZ" Guid="ABC-ETC">
                  <CreateFolder />
                </Component>
              </Directory>
            </Directory>
          </Directory>
        </DirectoryRef>
    

    并在您的feature 中引用组件CreateProgramDataZZZ

    这样设置目录的权限也很有帮助:

    <CreateFolder>
        <util:PermissionEx User="Users" GenericAll="yes" />
    </CreateFolder>
    

    (代替&lt;CreateFolder /&gt;

    【讨论】:

    • 任何人有想法创建文件夹并将文件移动到同一文件夹中?
    • 在 User= 上使用 WIX_ACCOUNT_USERS,因为其他语言的帐户会发生变化。
    【解决方案3】:

    这将为您创建文件夹...

    <Directory Id="DIR_ID" Name="DIR_NAME">
        <Component Guid="GUID" Id="id" KeyPath="no" NeverOverwrite="no" Permanent="no" Location="local">
            <CreateFolder>
                <util:PermissionEx CreateChild="yes" CreateFile="yes" Delete="yes" Read="yes" ReadAttributes="yes" ReadExtendedAttributes="yes" ReadPermission="yes" Traverse="yes" GenericRead="yes" GenericWrite="yes" User="Everyone" />
            </CreateFolder>
        </Component>
    </Directory>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-14
      相关资源
      最近更新 更多