8

WiX is complaining (what are the odds, right?):

Error 95 The component 'blahblah' has a key file with path 'TARGETDIR\blah.dll'. Since this path is not rooted in one of the standard directories (like ProgramFilesFolder), this component does not fit the criteria for having an automatically generated guid. (This error may also occur if a path contains a likely standard directory such as nesting a directory with name "Common Files" under ProgramFilesFolder.)

But I WANT an automatically generated GUID, and I DON'T want to have to set the TARGETDIR to some other path comprised of ProgramFilesFolder since I am setting the TARGETDIR in the UI and I even allow the user to change it so that people can specify the path they want to install the application at...how does someone get this functionality? Is it possible? I mean, can I have the best of both worlds or not? Why is it such a big deal? WiX is way too restrictive sometimes...

john k
  • 6,268
  • 4
  • 55
  • 59
Alexandru
  • 12,264
  • 17
  • 113
  • 208
  • 1
    WiX isn't complaining, Windows Installer is complaining. It's a big deal because the underlying Windows Installer has something called the component rules. Bad things happen when you break them. – Christopher Painter Sep 24 '14 at 17:38
  • Then don't use MSI. I understand your frustration... I spent a lot of time fighting MSI when I first learned it. It's a very rigid framework that doesn't like you coloring outside of the lines. But once you master it, there is a huge net gain in terms of developer productivity and quality of user experience. – Christopher Painter Sep 24 '14 at 17:47
  • Unfortunately its a standard that people have come to grips with, otherwise I wouldn't use it :) – Alexandru Sep 24 '14 at 17:49
  • 1
    BTW, I misspoke. That is WiX complaining. I misread the message. – Christopher Painter Sep 24 '14 at 18:05
  • @ChristopherPainter Either way, it doesn't matter who's complaining, what matters is that there was a solution to this all. – Alexandru Sep 24 '14 at 18:43
  • Duplicate of https://stackoverflow.com/questions/7328748/harvesting-files-leads-to-lght0231-error – john k Jul 01 '21 at 13:32

2 Answers2

9

All you need to do is set Directory/@ComponentGuidGenerationSeed and then you can use auto guids for non-standard folder.

Neil
  • 2,677
  • 1
  • 16
  • 9
  • This should be the accepted answer. I now set this on the top folder of my directory hierarchy. – Ed Bayiates Jun 14 '19 at 21:55
  • 1
    Um. How do I do this? – john k Jul 01 '21 at 13:17
  • yeah! Set ComponentGuidGenerationSeed where - on what directory element? @EdBayiates and to what value (it needs to be set to a GUID according to https://wixtoolset.org/documentation/manual/v3/xsd/wix/directory.html). Not even clear if I set this as a parameter to heat or in my Product.wxs – lewis Mar 31 '22 at 21:44
  • 2
    @lewis example: – Ed Bayiates Apr 04 '22 at 00:58
-1

I just got it...kind of annoying but its working alright...

I was modifying the TARGETDIR and working with it prior...but now, I realize that I can easily just have worked with INSTALLDIR...for example, I re-factored my directory structure as such:

<Directory Id='TARGETDIR' Name='SourceDir'>
  ...
  <Directory Id="ProgramFilesFolder">
    <Directory Id="blahFolder" Name="blah">
      <Directory Id="INSTALLFOLDER" Name="blah"/>
    </Directory>
  </Directory>
</Directory>

I can get components to reference the INSTALLFOLDER and it will auto-generate GUIDs for them:

<ComponentGroup Id='blahgroup'>
    <Component Id='blahId' Directory='INSTALLFOLDER' Transitive='no'>
      <RegistryKey Root='HKLM' Key='Software\blah\blah' ForceCreateOnInstall='no' ForceDeleteOnUninstall='no'>
        <RegistryValue Type='string' Name='blah' Value='BLAH' />
      </RegistryKey>
    </Component>
    ...
</ComponentGroup>

But in my UI, its nice because I can modify just the installation folder path quite well:

<Product ...>
  ...
  <CustomAction Id='SetInstallFolder' Property='INSTALLFOLDER' Value='[ProgramFilesFolder]blah\blah\'/>
  ...
</Product>

I can then force the INSTALLFOLDER to point anywhere I want:

<InstallUISequence>
  <Custom Action='SetInstallFolder' Sequence='1'/>
  ...
</InstallUISequence>
<AdminUISequence>
  <Custom Action='SetInstallFolder' Sequence='1'/>
  ...
</AdminUISequence>
Alexandru
  • 12,264
  • 17
  • 113
  • 208
  • 1
    I hope you realize that as authored your custom actions won't fire during silent installation. A bit more logic is required to handle silent installations, repairs and upgrades. – Christopher Painter Sep 25 '14 at 00:44
  • @ChristopherPainter Yeah, I know. Actually, I didn't need to use the actions anymore after I set up the folder structure the way I did. You can see how this was the initial problem. However, beyond that: For quiet installations, MSI packages export public properties, which you can set with the PROPERTY=value syntax on the end of the msiexec parameters. Anyways, I left it in the answer as a exercise/POC so that someone else might benefit from seeing how that may be done. – Alexandru Sep 25 '14 at 01:18