【问题标题】:Wix will not touch AppData Folder During InstallWix 在安装过程中不会触及 AppData 文件夹
【发布时间】:2014-05-16 01:26:42
【问题描述】:

所以我已经研究这个问题好几天了。我的安装程序根本不会在 Windows 中的漫游 AppData 文件夹中添加任何内容或从中删除任何内容。我是 Wix 新手,这是我的第一个安装程序。该程序还附带一个引导程序,它安装了各种先决条件和 .NET 框架。我使用的代码如下。

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="USBackup" Language="1033" Version="!(bind.fileVersion.USBackup.exe)" Manufacturer="Ed Rose" UpgradeCode="795ea019-054a-4f34-8c9a-cb4e607897c0">
    <Package Id="*" InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <Icon Id="icon.ico" SourceFile="..\USBackup\resources\usb.ico"/>
    <Property Id="ARPPRODUCTICON" Value="icon.ico" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
    <MediaTemplate EmbedCab="yes"/>

    <UIRef Id="WixUI_Minimal" />
    <UIRef Id="WixUI_ErrorProgressText" />

<PropertyRef Id="NETFRAMEWORK45"/>
<Condition Message='This setup requires the .NET Framework 4.5 installed.'>
  <![CDATA[Installed OR NETFRAMEWORK45]]>
</Condition>

    <Feature Id="ProductFeature" Title="Setup" Level="1">
        <ComponentGroupRef Id="ProductComponents" />
      <ComponentRef Id='ProgramMenuDir' />
  <ComponentRef Id='AppDataDir'/>
  <ComponentRef Id='DevicesDir'/>
    </Feature>
</Product>

<Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">

        <Directory Id="ProgramFilesFolder">
            <Directory Id="INSTALLFOLDER" Name="USBackup" />
        </Directory>

        <Directory Id="ProgramMenuFolder" Name="Programs">
            <Directory Id="ProgramMenuDir" Name="USBackup">
                <Component Id="ProgramMenuDir" Guid="{B01A59A5-ADA0-43FD-B14F-D479CD002E72}">
                    <RemoveFolder Id='ProgramMenuDir' On='uninstall' />
                    <RegistryValue Root='HKCU' Key='Software\[Manufacturer]\[ProductName]' Type='string' Value='' KeyPath='yes' />
                </Component>
            </Directory>
        </Directory>

  <Directory Id="CommonAppDataFolder" Name="CommonAppData">
    <Directory Id="AppDataDir" Name="USBackup">

      <Component Id="AppDataDir" Guid="{573BF504-1F52-40FE-A78A-96F43924379E}">
        <RemoveFolder Id="AppDataDir" On="uninstall"/>
        <RegistryValue Root='HKCU' Key='Software\[Manufacturer]\[ProductName]' Type='string' Value='' KeyPath='yes' />
      </Component>

      <Directory Id="DevicesDir" Name="Devices">
        <Component Id="DevicesDir" Guid="{E145EA47-109F-42E7-ABAB-4E9A87FEC464}">
          <RemoveFolder Id="DevicesDir" On="uninstall"/>
          <RegistryValue Root='HKCU' Key='Software\[Manufacturer]\[ProductName]' Type='string' Value='' KeyPath='yes' />
        </Component>

      </Directory>
    </Directory>
  </Directory>

    </Directory>
</Fragment>

<Fragment>
    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">

        <Component Guid="{9D9BA12C-0859-46F0-B5E1-2A59BE96F83D}">
            <File Source="$(var.USBackup.TargetPath)" KeyPath="yes">
              <Shortcut Id="start" Directory="ProgramMenuDir" Name="USBackup" WorkingDirectory='INSTALLDIR' Icon="icon.ico" IconIndex="0" Advertise="yes" />
            </File>
        </Component>

        <Component Guid="{6B473C52-6901-4FAC-A48B-20FC13A49C21}">
            <File Source="..\USBackup\bin\Release\AutoUpdater.NET.dll" KeyPath="yes"/>
        </Component>

        <Component Guid="{6191F8CC-98A8-4424-A846-44DC1EB2A22C}">
            <File Source="..\USBackup\bin\Release\USBackup.exe.config" KeyPath="yes"/>
        </Component>

        <Component Guid="{4E183A88-69DE-49D1-9142-13A2346443AF}">
            <File Source="..\USBackup\bin\Release\USBackup.exe.manifest" KeyPath="yes"/>
        </Component>

  <!--Set to open on startup-->
  <Component Id="RegistryKey" Guid="{8DBAB7DD-D9CD-4EC4-97F9-9A6131B40108}" Shared="yes">
    <RegistryKey Root="HKCU" Key="Software\Microsoft\Windows\CurrentVersion\Run">
      <RegistryValue Id="startupValue" Action="write" Name="USBackup" Value="[INSTALLFOLDER]USBackup.exe" Type="string"/>
    </RegistryKey>
  </Component>

    </ComponentGroup>
</Fragment>
</Wix>

它的构建没有错误或警告。为什么它不会触及 AppData 目录?

【问题讨论】:

  • 您可以尝试 Process Monitor(procmon,Sysinternals 工具的一部分)来查看运行时发生的情况。尝试打开目录时是否出错,或者可能为其生成了错误的名称?它通常很有启发性。
  • 你有 InstallScope="perMachine" .. AppData 是 perUser

标签: wix


【解决方案1】:

你没有给出任何理由让它创建它。

包括&lt;CreateFolder/&gt;,这样

 <Component Id="AppDataDir" Guid="{573BF504-1F52-40FE-A78A-96F43924379E}">
        <RegistryValue Root='HKCU' Key='Software\[Manufacturer]\[ProductName]' Type='string' Value='' KeyPath='yes' />
        <CreateFolder />
      </Component>

【讨论】:

  • 不幸的是,这不起作用-事实上,我曾经在其中有 标签,但由于某种原因,它不在我发布的 sn-p 中-可能我只是在尝试.我已经尝试将组件添加到主 ComponentGroup 并且也一直在使用不同的标签顺序,以防出现一些奇怪的错误导致它以不同的顺序工作,但无济于事。还有什么可以阻止它在该目录中添加或删除文件夹吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-06-21
  • 1970-01-01
  • 1970-01-01
  • 2013-09-09
相关资源
最近更新 更多