Riz
Riz

Reputation: 7002

WixToolset v4 - Installation with scope "perUser" fails without elevated permissions

I have a small application for which I made a wix 3 setup that installed it to the local AppData folder. This never required admin permissions and it worked flawlessly.

Recently I upgraded to Wix 4 that auto-converted wxs files to Wix 4 format. But now it started to ask for elevated permissions to install the setup. I added Scope="perUser" to it to avoid it from asking for elevated permissions, but now Setup fails with an error

Error 0x80070005: Failed to secure cache path: C:\ProgramData\Package Cache
Error 0x80070005: Failed to secure cache directory: C:\ProgramData\Package Cache
Error 0x80070005: Failed to secure per-machine cache root. Failed to prepare package: NetFx462Redist, error: 0x80070005 Error 0x80070005: Cache prepare package failed: NetFx462Redist Error 0x80070005: Failed while caching, aborting execution.

Why is this happening and how can I avoid that?

Here is my product.wxs

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
  <?include common.wxi ?>
  
  <Package Name="$(var.PRODUCT) $(var.VERSION)" UpgradeCode="$(var.UPGRADECODE)" Language="1033" Codepage="1252" Version="$(var.VERSION)" Manufacturer="$(var.MANUFACTURER)" InstallerVersion="200" Scope="perUser">
    <SummaryInformation Keywords="Installer, MSI, Package" Manufacturer="$(var.MANUFACTURER)" />

    <MajorUpgrade Schedule="afterInstallInitialize" DowngradeErrorMessage="$(var.DOWNGRADEERRORMESSAGE)" />
    <MediaTemplate EmbedCab="yes" />
    <Property Id="ApplicationFolderName" Value="$(var.MANUFACTURER)\$(var.PRODUCT)" />

    <Feature Id="DefaultFeature" Level="1">
        <ComponentRef Id="INSTALLDIRComponent" />
    </Feature>
  
      <StandardDirectory Id="LocalAppDataFolder">
        <Directory Id="INSTALLDIR" Name="MyApp">
        
          <Component Id="INSTALLDIRComponent" Guid="$(var.INSTALLDIRGUID)" Bitness="always64">
            <File Id="___var_MyApp.exe" Source="$(var.MyApp.TargetDir)MyApp.exe" />
            <File Id="mainExecutableFile" Source="$(var.MyApp.TargetDir)MyApp.Launcher.exe" />

            <RegistryValue Root="HKCU" Key="Software\MyApp\MyApp" Name="Exe" Value="[INSTALLDIR]MyApp.exe" Type="string" />
            <RegistryValue Root="HKCU" Key="Software\MyApp\MyApp" Name="Path" Type="string" Value="[INSTALLDIR]" KeyPath="yes" />

            <RemoveFolder Id="INSTALLDIRfolder" Directory="INSTALLDIR" On="uninstall" />

          </Component>
        </Directory>
      </StandardDirectory>
    
    </Package>
</Wix>

And Bundle.wxs

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal">

  <Bundle Name="MyApp" Version="$(var.Version)" Manufacturer="MyApp" UpgradeCode="97baf4b4-4e07-43bb-9042-df6bf3e29f6e">

    <bal:Condition Message="You’re using an unsupported version of Windows. MyApp requires Windows 7 SP1 or later." Condition="((VersionNT &gt;= v5.1) AND (ServicePackLevel &gt;= 3)) OR ((VersionNT &gt;= v5.2) AND (ServicePackLevel &gt;= 2)) OR ((VersionNT &gt;= v6.1) AND (ServicePackLevel &gt;= 1)) OR (VersionNT &gt;= v6.2)" />
    
    <Variable Name="LaunchTarget" Value="[LocalAppDataFolder]\MyApp\MyApp.Launcher.exe" Type="formatted" />

    <BootstrapperApplication>
      <bal:WixStandardBootstrapperApplication LogoFile="Resources/[email protected]" ThemeFile="Resources/ClassicTheme.xml" LocalizationFile="Resources/ClassicTheme.wxl" LicenseUrl="" Theme="hyperlinkSidebarLicense" />
    </BootstrapperApplication>

    <Chain DisableSystemRestore="yes">
      <PackageGroupRef Id="NetFx462Redist" />
      <RollbackBoundary />
      
      <MsiPackage Id="SetupAdmin" Compressed="yes" SourceFile="$(var.MSIInstaller.TargetDir)MyApp.msi" Vital="yes">
        <MsiProperty Name="INSTALLLOCATION" Value="[INSTALLDIR]" />
        <MsiProperty Name="BUNDLEKEY" Value="[WixBundleProviderKey]" />
      </MsiPackage>
    </Chain>
  </Bundle>
</Wix>

Upvotes: 1

Views: 419

Answers (1)

Rob Mensching
Rob Mensching

Reputation: 36006

The NetFx462Redist is probably marked to be always cached (a new feature in v4), so Burn wants to cache it. That's a per-machine package, so Burn should require elevation to cache the per-machine package. However, your Bundle overall is now per-user (because of the per-user package), so maybe Burn is skipping the elevation. It's hard to tell because you only provide a snippet of the log file.

If my guess is correct, this could be a bug in Burn. But I could be missing something. You should probably debug Burn to know for sure.

Upvotes: 1

Related Questions