meh93
meh93

Reputation: 334

HarvestDirectory nesting folders when they should be

So I have this in my .wixproj

<DefineConstants>ProductVersion=$(ProductVersion);backendDir=backend;frontendDir=frontend;hardwareDir=hardware</DefineConstants>

    .....

  <ItemGroup>
    <Compile Include="Product.wxs" />
  </ItemGroup>
  <HarvestDirectory Include="frontend">
      <DirectoryRefId>frontendDir</DirectoryRefId>
      <ComponentGroupName>frontendComp</ComponentGroupName>
      <PreprocessorVariable>var.frontendDir</PreprocessorVariable>
    </HarvestDirectory>
    <HarvestDirectory Include="backend">
      <DirectoryRefId>backendDir</DirectoryRefId>
      <ComponentGroupName>backendComp</ComponentGroupName>
      <PreprocessorVariable>var.backendDir</PreprocessorVariable>
    </HarvestDirectory>
    <HarvestDirectory Include="hardware">
      <DirectoryRefId>hardwareDir</DirectoryRefId>
      <ComponentGroupName>hardwareComp</ComponentGroupName>
      <PreprocessorVariable>var.hardwareDir</PreprocessorVariable>
    </HarvestDirectory>

And then in the Product.wxs I have:

    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLDIR" Name="FlexxEdge">
          <Directory Id="frontendDir" Name="frontend"/>
          <Directory Id="backendDir" Name="backend"/>
          <Directory Id="hardwareDir" Name="hardware"/>
        </Directory>
      </Directory>
...
     <Feature Id="Software" 
             Title="testInstaller" 
             Level="1"
             ConfigurableDirectory="INSTALLDIR">
      <ComponentGroupRef Id="frontendComp" />
      <ComponentGroupRef Id="backendComp" />
      <ComponentGroupRef Id="hardwareComp" />
    </Feature>

So it works and it installs, but for some reason the frontend and hardware folders are nested when they shouldn't be. The backend folder is fine. File structure - what it should be:

- frontend
- - Files
- backend
- - Files
- hardware
- - Files

What it is after the installer:

- frontend
- - frontend
- - - Files
- backend
- - Files
- hardware
- - hardware
- - - Files

And I checked the actual dirs and they don't have this issue in the project.

Upvotes: 1

Views: 224

Answers (1)

meh93
meh93

Reputation: 334

So it took a bit of debugging, building and testing, but I finally found the issue.

In Product.wxs I needed to remove the name field on the directories.

...
        <Directory Id="INSTALLDIR" Name="FlexxEdge">
          <Directory Id="frontendDir"/>   <-no name field here!
          <Directory Id="backendDir"/>
          <Directory Id="hardwareDir"/>

With the name field there is was telling it to put it into a directory called Name and I was already referencing the whole directory so it was nesting it. So for harvesting - just use the directory ref!

I recall in another area of this file the Name function referenced the parent directory - not the one I was working in. So I would recommend being careful with the name field. To be fair, in the documentation on Directory the Name field is "The name of the directory.". So I thought I needed it here. Apparently not.

However it doesn't explain why the backend folder was fine for a while (after several builds it finally had the nested folder issue as well). That was the strangest part of it all, but after seeing that it was a bit easier to track down the issue.

Upvotes: 1

Related Questions