代码之家  ›  专栏  ›  技术社区  ›  Alex Zhukovskiy

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

  •  1
  • Alex Zhukovskiy  · 技术社区  · 6 年前

    我正在尝试创建一个安装程序来安装我的 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 回复  |  直到 6 年前
        1
  •  2
  •   Stein Åsmul    6 年前

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


    :您似乎忽略了 Directory attribute RemoveFolder element

    在您的情况下是必需的(因为 默认为宿主组件安装目录,否则-在本例中不正确)。


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

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

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


    下面是一个更大的wix Blurb:

    <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>
    
    推荐文章