Component testcomp installs to user profile. It mu

2019-04-04 15:01发布

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>

标签: wix
1条回答
老娘就宠你
2楼-- · 2019-04-04 15:44

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.

查看更多
登录 后发表回答