如何在 AppData 中创建嵌套文件夹

How to create nested folder in AppData

我正在尝试创建一个安装程序,将我的 DApp 安装到以太坊客户端。

为此,我只需将我的文件复制到 %appdata%\Parity\Ethereum\dapps\mydappname。所以我有这个标记,它在 %appdata%\mydappname:

中创建了一个文件夹
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="*" Name="MyDapp" Language="1049" Version="1.0.0.0" 
             Manufacturer="Orbita" UpgradeCode="PUT-GUID-HERE" Codepage="1251">

      <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
      <MediaTemplate EmbedCab="yes"/>

        <Feature Id="ProductFeature" Title="MyDapp" Level="1">
            <ComponentGroupRef Id="ProductComponents" />
        </Feature>
    </Product>

    <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
          <Directory Id="AppDataFolder">
            <Directory Id="INSTALLFOLDER" Name="Fairs" />
          </Directory>
        </Directory>
    </Fragment>

    <Fragment>
        <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
          <Component Id="dapp" Guid="PUT-GUID-HERE">
            <RemoveFolder Id="INSTALLFOLDER" On="uninstall" />
            <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" 
                           Type="string" Value="" KeyPath="yes" />
            <File Id="chain.json" Source="..\..\..\..\config\chain.json"/>
          </Component>
        </ComponentGroup>
    </Fragment>
</Wix>

但是,当我将结构更改为嵌套时:

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="AppDataFolder">
        <Directory Id="Parity" Name="Parity">
          <Directory Id="Ethereum" Name="Ethereum">
            <Directory Id="dapps" Name="dapps">
              <Directory Id="INSTALLFOLDER" Name="Fairs" />
            </Directory>
          </Directory>
        </Directory>
      </Directory>
    </Directory>
  </Fragment>

我得到 ICE64s:

ICE64: The directory Parity is in the user profile but is not listed in the RemoveFile table.
ICE64: The directory Ethereum is in the user profile but is not listed in the RemoveFile table.
ICE64: The directory dapps is in the user profile but is not listed in the RemoveFile table.

标记有什么问题?我尝试将 RemoveDirectory 更改为

<RemoveFolder Id="Parity" On="uninstall" />

但是没用。

Per-User vs Per-Machine:出于多种原因,通常不建议安装到每个用户的文件夹(用户配置文件) .安装到每台机器的路径是不可能的吗?您的应用程序是否需要从每个用户的文件夹中 运行?


ICE64:看起来你在 RemoveFolder element.[=16 中省略了 Directory attribute =]

在您的情况下这是必需的(因为 Directory attribute 否则默认为托管组件安装目录 - 在这种情况下这是不正确的)。


要解决您的验证错误,您应该可以这样做:

改变这个:

<RemoveFolder Id="Parity" On="uninstall" />

对此:

<RemoveFolder Id="Parity" Directory="Parity" On="uninstall" />

对用户配置文件中存在的所有文件夹执行此操作。


这是一个更大的 WiX 简介:

<Component Feature="MyFeature" Guid="PUT-GUID-HERE">

    <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]\Test"
                   Name="installed" Type="integer" Value="1" KeyPath="yes"/>

    <File Source="TestFile.txt" />

    <RemoveFolder Id="Parity" Directory="Parity" On="uninstall" />
    <RemoveFolder Id="Ethereum" Directory="Ethereum" On="uninstall" />
    <RemoveFolder Id="dapps" Directory="dapps" On="uninstall" />
    <RemoveFolder Id="INSTALLFOLDER" Directory="INSTALLFOLDER" On="uninstall" />

</Component>