I'd like to copy a file under a Doucments location in WiX. But it gives the warning:
Component testcomp installs to user profile. It must use a registry key under HKCU as its KeyPath, not a file.
My code:
<Directory Id='PersonalFolder' Name='MyDocuments'>
<Component Id='testcomp' Guid='08C288B6-D8E0-4036-9CEB-E5F616AC6B5C'>
<File Id='doc_code_file1' Name='doc_code_file1' DiskId='1'
Source='Personalfolder\Visual Studio 2012\Code Snippets\Visual C#\My Code Snippets\SimpleMvvm\mvvmcommand.snippet' KeyPath='yes'></File>
</Component>
</Directory>
That's correct. The Windows Installer wants registry keys as the key paths for per-user Components. It has to do with the way profiles work with advertised content in enterprise deployments. The fix is very straight forward:
<Directory Id='PersonalFolder' Name='MyDocuments'>
<Component Id='testcomp' Guid='08C288B6-D8E0-4036-9CEB-E5F616AC6B5C'>
<RegistryValue Root='HKCU' Key='Software\Manufacturer\Product'
Name='Something (I like to use InstallFolder)'
Value='Something (I like to use [INSTALLFOLDER]'
Type='string'
KeyPath='yes' />
<File Id='doc_code_file1' Name='doc_code_file1' DiskId='1'
Source='Personalfolder\Visual Studio 2012\Code Snippets\Visual C#\My Code Snippets\SimpleMvvm\mvvmcommand.snippet' />
</Component>
</Directory>
Note: The added per-user registry key and that it is marked KeyPath='yes'
. The latter is not explicitly necessary since it's the first resource in the Component which will be marked as the key path by default, but being explicit with the key path is sometimes better.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With