How do I install to LocalAppData folder?

前端 未结 4 1082
囚心锁ツ
囚心锁ツ 2021-02-18 14:42

Following directory setting works perfectly for me.


  

        
相关标签:
4条回答
  • 2021-02-18 14:43

    I had this problem recently. I wanted to convert my installer from per-machine to a per-user but was getting ICE38. I asked on wix-users and one opinion was that you can ignore ICE38 because that was meant as a check for per-machine installs.

    See the discussion at wix-users.

    Since that is the case, ICE38 is (in my opinion) incorrect and you will want to ignore it. ICE38 implies you are installing per-user resources in the context of a per-machine installation but never verifies that this is so.

    Actually authoring a per-user install requires that you ignore ICE38 because it won't ever be accurate for that world.

    [Edit] Looks like you got help here.

    From Peter Shirtcliffe:

    This is my own, admittedly inexpert, understanding of per-user installations:

    Installing to subdirectory of LocalAppDataFolder is perfectly OK in a per-user MSI. Because of certain scenarios relating to roaming users, you need to add components containing elements for any directories you create under LocalAppDataFolder. That's why ICE64 is appearing.

    The ICE38 error is slightly misleading: since you have a per-user installation, it's safe to ignore as long as the user cannot pick an alternative installation location that is common to all users. ICE38 is checking for the situation where multiple users all install the same component to the same path.

    Just posting to help other people (like me).

    0 讨论(0)
  • 2021-02-18 14:48

    Are you installing per-user or per-machine? Also, what OS versions are you targetting? You might want to read:

    Authoring a single package for Per-User or Per-Machine Installation context in Windows 7

    0 讨论(0)
  • 2021-02-18 14:56

    Ok, just found that we can do it by overwriting "ProgramFilesFolder":

    <SetProperty Id="ProgramFilesFolder" Value="[LocalAppDataFolder]" Before="CostFinalize"><![CDATA[NOT Privileged]]></SetProperty>
    

    Another thing to do is, in <Package> we need to set InstallPrivileges to limited.

    Well, I can see no reason why "ProgramFilesFolder" can be used directly while "LocalAppDataFolder" can't.

    0 讨论(0)
  • 2021-02-18 14:59

    I converted an application from being a perMachine install to be a perUser install. In order to properly convert the install I had to add a registry key for each of the components I have.

    Originally I had the following:

    <Component Id="C.MyExe">
      <File Id="Fi.MyExe" Name="$(var.MyExe.TargetFileName)" Source="$(var.MyExe.TargetPath)" DiskId="1">
        <Shortcut Id="SC.StartMenu"
                  Directory="D.ApplicationMenuDir"
                  Name="$(var.AppName)"
                  WorkingDirectory="INSTALLDIR"
                  Icon="MY_ICON.ico"
                  IconIndex="0" 
                  Advertise="yes"
          />
          ...
    

    When I moved the exe component to the user install I had to do something like this:

    <Directory Id="LocalAppDataFolder" Name="AppData">
      <Directory Id="MyAppDirectory" Name="$(var.AppName)">
        <Component Id="C.MyExe" Guid="{MY_GUID}">
          <CreateFolder />
          <RemoveFolder Id="RemoveMyAppDirectory" On="uninstall" />
          <RegistryKey Root="HKCU" Key="Software\MyCompany\MyApp">
            <RegistryValue Name="MainExe" Value="1" KeyPath="yes" Type="integer" />
          </RegistryKey>
          <File Id="Fi.MyExe" Name="$(var.MyExe.TargetFileName)"
              Source="$(var.MyExe.TargetPath)" DiskId="1" Checksum="yes">
          </File>
        </Component>
       ...
    

    The most important part is that you will have to add a registry key which points to HKEY_CURRENT_USER. I added a registry value for each component which indicates that the component is installed.

    I also had to remove the following: Advertise="yes".

    0 讨论(0)
提交回复
热议问题