将WIX fragement的文件安装到Public Documents

时间:2016-03-22 16:18:38

标签: wix windows-installer

My WIX安装程序有2个片段,一个转到x64 Program Files,工作正常。我正在尝试使用heat来为需要类似

的文件生成一个wxs片段
"C:\Users\Public\Documents\MyAppPublic"

在.wixproj文件中,我有以下BeforeBuild代码:

<Target Name="BeforeBuild">
    <HeatDirectory 
        Directory="$(SolutionDir)\..\..\MyApp\MyApp.Application\bin" 
        OutputFile="$(SolutionDir)\..\MyApp\Fragments\InstallFiles.wxs" 
        ComponentGroupName="MyAppInstallFilesComponentGroup" 
        DirectoryRefId="MYAPPINSTALLDIRECTORY" 
        PreprocessorVariable="var.ProjectSourceFilesDir" 
        AutogenerateGuids="true" 
        ToolPath="$(SolutionDir)\..\tools\3.10\binaries" 
        SuppressFragments="true" 
        SuppressCom="true" 
        SuppressRegistry="true" 
        SuppressRootDirectory="true" 
        Transforms="$(SolutionDir)\..\MyApp\Transforms\InstallFilesExclude.xsl" />
    <HeatDirectory 
        Directory="$(SolutionDir)\..\..\MyAppPublicDocsSourceFiles" 
        OutputFile="$(SolutionDir)\..\MyApp\Fragments\MyAppPublicDocsFiles.wxs" 
        ComponentGroupName="MyAppPublicFilesComponentGroup" 
        DirectoryRefId="MYAPPPUBLICDIRECTORY" 
        PreprocessorVariable="var.MyAppPublicDocsSourceDir" 
        AutogenerateGuids="true" 
        ToolPath="$(SolutionDir)\..\tools\3.10\binaries" 
        SuppressFragments="true" 
        SuppressCom="true" 
        SuppressRegistry="true" 
        SuppressRootDirectory="true"/>
</Target>

我的MyAppPublicDocsFiles.wsx文件正在填充。我正在使用Visual Studio编译包含我的.wixproj文件的解决方案。我看到的错误是:

1>C:\Users\user.name\...\MyApp\Fragments\MyAppPublicDocsFiles.wxs(55,0): error LGHT0231: 
   The component 'cmp415810817DCD69555E8A9CBFB0AA536A' has a key file with path 
   'TARGETDIR\publicdocs\MyAppPublicDocs\file1.txt'.  
   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.)
1>Done building project "MyApp.wixproj" -- FAILED.

对我的公共文档源目录中的每个文件重复。

这是我的.wixproj代码:

<PropertyRef Id="WIX_DIR_COMMON_DOCUMENTS"/>

<Feature Id='MyAppInstallFiles' Title='MyApp Install Files' Description='The application'>
  <Feature Id='ApplicationFiles' Title='MyApp Application Files' Description='Application Files' Level='1'>
    <ComponentGroupRef Id='MyAppInstallFilesComponentGroup' />
  </Feature>
</Feature>

<Feature Id='MyAppPublicDocFiles' Title='PublicDoc Files' Description='Data files'>
  <Feature Id='PublicDocFiles' Title='PublicDoc  Files' Description='Data files' Level='1'  ConfigurableDirectory='MYAPPPUBLICDIRECTORY'>
    <ComponentGroupRef Id='MyAppPublicDocFilesComponentGroup' />
  </Feature>
</Feature>

<Directory Id='TARGETDIR' Name='SourceDir'>
  <Directory Id='ProgramFiles64Folder' Name='PFiles'>
    <Directory Id='$(var.ShortManufacturer)' Name='$(var.ShortManufacturer)'>
      <Directory Id='SOLIDXINSTALLDIRECTORY' Name='$(var.ProductName)'>
      </Directory>
    </Directory>
  </Directory>      
  <Directory Id="WIX_DIR_COMMON_DOCUMENTS" Name="PublicDocs">
    <Directory Id='MYAPPPUBLICDIRECTORY' Name='$(var.PublicDocName)'/>
  </Directory>
</Directory>

如何解释此错误消息?总之,我正在尝试将WIX片段文件安装到公共文档位置。 This question将文件直接放在.wixproj中,并列在该XML节点下。我的文件来自heat.exe。

1 个答案:

答案 0 :(得分:1)

要使用自动GUID生成,路径必须在构建时生根。在安装时间之前未分配WIX_DIR_COMMON_DOCUMENTS

你可以在构建时根据它来解决这个问题,例如[CommonAppDataFolder]