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

时间:2018-06-17 17:27:34

标签: wix windows-installer installer

我正在尝试创建一个安装程序,将我的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>

我得到ICE64 s:

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" />

但它没有用。

1 个答案:

答案 0 :(得分:2)

每用户与每台计算机 :由于多种原因,通常不建议安装到每用户文件夹(用户配置文件)。安装到每台计算机的路径是不可能的?您的应用程序是否需要从每用户文件夹运行?

ICE64 :您似乎已在Directory attribute中省略了RemoveFolder element

在您的情况下是必需的(因为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>