【问题标题】:How to create nested folder in AppData如何在 AppData 中创建嵌套文件夹
【发布时间】:2018-06-18 05:22:58
【问题描述】:

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

但它不起作用。

【问题讨论】:

    标签: wix windows-installer installation


    【解决方案1】:

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


    ICE64:看起来你在RemoveFolder element 中省略了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>
    

    【讨论】:

    • 好吧,不幸的是我需要按用户安装,因为我将它构建在另一个按用户安装的安装之上。也许我只是在perMachne 上做错了,因为我实际上需要perUser
    • 好的,每个用户的东西都具有挑战性 - 但只要它适用于您的部署方案。每台机器的设置可以包含每用户的数据,但是当他们登录和/或调用产品时,您需要使用a suitable mechanism 将用户特定的文件复制到每个用户的用户配置文件文件夹中。我会输入one more link on userprofile files。是的,如果您只有每个用户的文件,您可以将 InstallScope 设置为 perUser。
    最近更新 更多