wixtoolset / issues

WiX Toolset Issues Tracker
http://wixtoolset.org/
129 stars 36 forks source link

Setting the "Scope" property to "perUser" results in an unexpected INSTALLFOLDER path #8101

Open antoinebj opened 5 months ago

antoinebj commented 5 months ago

WiX Version

5.0.0

.NET or MSBuild or Visual Studio Version

.NET 8.0 / VS 2022 17.9.5

HeatWave Version

1.0.3

Windows Version

Win11 23H2

Repro Repo

No response

Repro Steps

Actual Result

At runtime, INSTALLFOLDER is in C:\Program Files

Expected Result

At runtime, INSTALLFOLDER is in %LOCALAPPDATA%\Programs

Note that if I set the scope to perUserOrMachine, the folder is as expected, but that makes the bundle configure itself to request elevated privileges

Acknowledgements

antoinebj commented 5 months ago

If I try to work around it by changing the target folder to this:

<StandardDirectory Id="LocalAppDataFolder">
  <Directory Name="Programs">
    <Directory Name="Contoso">
      <Directory Id="INSTALLFOLDER" Name="Contoso App" />
    </Directory>
  </Directory>
</StandardDirectory>

Then I get ICE38 errors:

Component xxxx installs to user profile. It must use a registry key under HKCU as its KeyPath, not a file.

And ICE91 warnings:

The file 'xxxx' will be installed to the per user directory 'INSTALLFOLDER' that doesn't vary based on ALLUSERS value. This file won't be copied to each user's profile even if a per machine installation is desired.

So that does not seem to be a viable workaround.

antoinebj commented 5 months ago

Apparently this has been the behavior for a long time: https://stackoverflow.com/questions/43981922/wix-installer-ignoring-my-peruser-install-scope-why

And the problem was already raised here: https://github.com/wixtoolset/issues/issues/7617 But then converted to a discussion without explanation, and then apparently forgotten.

Using perUserOrMachine instead would be viable, if there was a ForcePerUser property on MsiPackage for the Burn bundle, or if the InstallPrivileges property was brought back to explicitly specify limited privilege requirements.

antoinebj commented 5 months ago

One potential workaround:

<SetProperty Id="INSTALLFOLDER" Value="[LocalAppDataFolder]Programs\!(bind.Property.ProductName)" Sequence="first" Before="FindRelatedProducts" />

However, I don't know if that plays well with various languages, "Programs" might vary from locale to locale, just like "Program Files" does.

In the end, I may have to resort to coding a custom action, using SHGetKnownFolderPath with FOLDERID_UserProgramFiles, which would be quite the defeat for such a simple scenario.