Wednesday, December 17, 2008

wix - It must use a registry key under HKCU as its KeyPath, not a file.

Took me a few minutes to figure out my problem with this error in wix: It must use a registry key under HKCU as its KeyPath, not a file.

My original code:
<Directory Id="AppDataFolder" Name="AppDataFolder">
  <Directory Id="MyAppFolder" Name="My">
    <Component Id="MyComponent" Guid="cc509cb7-c1a1-46cf-8c62-7cbb0017783c">
      <File Id="test1.txt" Name="test1.txt" KeyPath="yes" Source="Files\test1.txt" />
    </Component>
  </Directory>
</Directory>

This is what it needed to be:
<Directory Id="AppDataFolder" Name="AppDataFolder">
  <Directory Id="MyAppFolder" Name="My">
    <Component Id="MyComponent" Guid="cc509cb7-c1a1-46cf-8c62-7cbb0017783c">
    <RegistryKey Action="none" Key="myKeyName" Root="HKCU" >
         <RegistryValue Type="integer" Value="1" KeyPath="yes" />
    </RegistryKey>
      <File Id="test1.txt" Name="test1.txt" KeyPath="yes" Source="Files\test1.txt" />
    </Component>
  </Directory>
</Directory>