How to include a modifiable loose file in WiX burn?
Asked Answered
B

2

6

I have a setup package including a non-compressed file.

<DirectoryRef Id="INSTALLLOCATION">
  <Component Id="LocationConfig">
    <File Id="LocationConfigFile" 
          Source="LooseFile.Config" 
          DiskId="2" 
          Vital="no" 
          Compressed="no" />
  </Component>
</DirectoryRef>

The purpose of this file being loose is so it can be edited before installation. This works as desired.

I have a burn chain specifying that the loose file is included as a loose file alongside the bootstrapper. Note also the use of SuppressLooseFilePayloadGeneration to allow the manual specification of the file as a loose payload.

<Chain>
  <MsiPackage SourceFile="MyInstaller.msi" 
              Visible="yes" 
              Vital="no"
              SuppressLooseFilePayloadGeneration="yes">
    <Payload Compressed="no" SourceFile="LooseFile.Config" />
  </MsiPackage>
</Chain>

The burn log looks like this:

[3860:38D8][2013-04-26T16:42:48]e000: Error 0x80091007: Hash mismatch for path: C:\ProgramData\Package Cache\.unverified\payAC32431CF002C09E2F0B537A32ACA259
[3860:38D8][2013-04-26T16:42:48]e000: Error 0x80091007: Failed to verify hash of payload: payAC32431CF002C09E2F0B537A32ACA259
[3860:38D8][2013-04-26T16:42:48]e310: Failed to verify payload: payAC32431CF002C09E2F0B537A32ACA259 at path: C:\ProgramData\Package Cache\.unverified\payAC32431CF002C09E2F0B537A32ACA259, error: 0x80091007. Deleting file.
[3860:38D8][2013-04-26T16:42:48]e000: Error 0x80091007: Failed to cache payload: payAC32431CF002C09E2F0B537A32ACA259
[33FC:3A54][2013-04-26T16:42:48]e314: Failed to cache payload: payAC32431CF002C09E2F0B537A32ACA259 from working path: C:\Users\Snixtor\AppData\Local\Temp\{c887e0cf-5038-4e15-95b1-8510d8c96b88}\payAC32431CF002C09E2F0B537A32ACA259, error: 0x80091007.

OK, the hash is failing because the file has changed. But... I want to allow the user to change the file. I can readily enough do this with a standard setup package, so what hoops do I have to jump through to get it to behave with a bootstrapper?

I found this discussion in the WiX users mailing list. Robs response of "It should just work" sounds promising, but then the discussion seems to move on to suggest it could be a bug? If the author ever raised a bug report, I can't find it.

An alternative I considered was to exclude the file altogether from the bootstrap payload, and then manually copy it over to the MSI cache path during install so the MSI can find it, though burn will never try to validate it. But the two troubles I see there are:

  1. I can't find out how to discover the cache path from within my bootstrapper.
  2. Even if I knew the path, I'd need to elevate the bootstrapper to copy the file. That may not be a showstopper, but I have a sneaking suspicion it might prove difficult.
Brack answered 26/4, 2013 at 6:57 Comment(0)
I
5

This isn't supported today. Burn validates everything before placing it in the cache for security reasons. What you could do is read the external file in a custom Bootstrapper Application and store the results as persisted Variables. This will be more work but Burn just won't trust files that don't match the security hashes/signatures inserted at build time.

Ingesta answered 26/4, 2013 at 13:12 Comment(2)
Thanks Rob, it's great to know the facts of the situation instead of shooting in the dark. I was thinking working with Variables might be an alternative. I'll look into it. Fortunately the config file I'm working with is quite simple.Brack
I have the same issue and I'm not sure I understand the answer. Is there an example for this anywhere? I basically need both the bootstrapper (for prerequisites), and the .msi + loose files that can be substituted before install. Installing the MSI by itself with the loose files works perfectly (as long as you already have the prerequisites).Concessive
R
2

I worked around this same issue by hanging off the current directory property that the burn bootstrapper sets and using it with a copyfile element like so:

  <Component Id="SettingsFile" Guid="...">
    <CopyFile Id="Copy" Delete="no" DestinationDirectory="INSTALLFOLDER" SourceName="LooseSettings.xml" SourceProperty="CURRENTDIRECTORY" />
    <RemoveFile Id="Remove" On="uninstall" Directory="INSTALLFOLDER" Name="LooseSettings.xml" />
  </Component>

There are quite possibly some issues with it but I'm writing an installer to someone else's specs and it seems to work

Reciprocate answered 31/3, 2014 at 20:22 Comment(1)
I was able to get something similar to work for my needs also. Nice tip.Concessive

© 2022 - 2024 — McMap. All rights reserved.