复制条件未在MSBuild中实际复制的文件

时间:2013-08-15 01:07:17

标签: msbuild wix

我正在使用WIX和MSBuild。我试图将com库和.ttf文件复制到两个不同的位置,我想使用WIX注册com库。当我使用Visual Build Pro运行它时,我没有看到任何错误或警告,我可以看到复制脚本被添加到安装文件中。但安装完设置后,文件不会复制到指定的目录。

Build.msbuild <Target>如下:

<Target Name="Setup">
<!-- Setup the source directory structure as it should appear on the target machine -->

<ItemGroup>
  <DeployFiles Include="$(Includes)" Exclude="$(Excludes)" />
  <PostHarvestFiles Include="$(PostHarvestIncludes)" Exclude="$(PostHarvestExcludes)" />
</ItemGroup>

<MakeDir Directories="$(OutputDir)" />
<MakeDir Directories="$(FinalOutputDir)" />
<MakeDir Directories="$(FilesToInstallDir)" />

<!-- Harvest the newly created directory structure for the MSI -->
<Copy SourceFiles="@(DeployFiles)" DestinationFiles="@(DeployFiles->'$(FilesToInstallDir)\%(RecursiveDir)%(Filename)%(Extension)')" />    
<Exec Command='$(BuildToolsDir)\Wix\heat.exe dir "$(FilesToInstallDir)" -dr INSTALLDIR -gg -cg FilesToInstall -sfrag -srd -sreg -out "$(MSBuildThisFileDirectory)Files.wxs" -var var.BaseDir' />

 <Copy Condition="'%(Extension)' == '.ttf'" SourceFiles="@(PostHarvestFiles)"  DestinationFiles="@(PostHarvestFiles->'$(FilesToInstallDir)\%(RecursiveDir)%(Filename)%(Extension)')" />

<!-- Harvest the old renderer DLL. This is a COM object and needs special handling -->
<Copy Condition="'%(Extension)' == '.dll'" SourceFiles="@(PostHarvestFiles)" DestinationFiles="@(PostHarvestFiles->'$(ComFilesToInstallDir)\%(RecursiveDir)%(Filename)%(Extension)')" />
<Exec Command='$(BuildToolsDir)\Wix\heat.exe file "$(ComFilesToInstallDir)\ComSrv.dll" -dr COMINSTALLDIR -ag -cg COMObjectsToInstall -out "$(MSBuildThisFileDirectory)COMDlls.wxs" -var var.ExternalsDir' />
</Target>


 <Target Name="CompileWix" DependsOnTargets="Setup">
 <!--  Create the Wix object files for linking in the next task  -->
<ItemGroup>
  <WixFiles Include="$(SourceDir)\Installer-Website\*.wxs" />
</ItemGroup>

<!-- Compile the Wix object files -->
<Exec Command="$(BuildToolsDir)\Wix\candle.exe -dBaseDir=&quot;$(FilesToInstallDir)&quot; -dBuildToolsDir=&quot;$(BuildToolsDir)&quot; -dExternalsDir=&quot;$(SourceDir)\ExternalAssembly&quot; -dFinalVersion=$(FinalVersion) -ext WiXNetFxExtension -ext WixIisExtension -out $(OutputDir)\ @(WixFiles->'%(Filename)% (Extension)',' ')" />
</Target>


<Target Name="BuildMsi" DependsOnTargets="CompileWix">
<!--   Link the Wix object files into the final MSI -->
<ItemGroup>
  <WixObjectFiles Include="$(OutputDir)\*.wixobj" />
</ItemGroup>

<!--  Link the Wix object files into the final MSI  -->
<Exec Command="$(BuildToolsDir)\Wix\light.exe -cultures:en-us -loc      &quot;$(MSBuildThisFileDirectory)WebAppInstallDlg_en-us.wxl&quot; -sice:ICE17 -sice:ICE38 -sice:ICE43 -sice:ICE57 -sice:ICE64 -ext WixUIExtension -ext WiXNetFxExtension -ext WixIisExtension -out $(OutputDir)\$(MsiName) @(WixObjectFiles->'%(FullPath)',' ')" />
<Copy SourceFiles="$(OutputDir)\$(MsiName)" DestinationFolder="$(FinalOutputDir)" />

 </Target>

带有目录的Product.wxs文件如下:

 <Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="INSTALLDIR" Name="$(var.BaseProductName)">
    <Directory Id="FontsFolder">
      <Component Id="cmp_FontsToInstall" Guid="{C286A08B-28CB-4A62-9BF8-833A6B141CB4}">
        <File Id="fil82FBA6D3A96B47C48C72FA2F03739758" KeyPath="yes" TrueType="yes" Source="$(var.BaseDir)\OOCA.ttf" />
      </Component>        
    </Directory>

    <Directory Id="COMINSTALLDIR" >
      <Component Id="COMObjectsToInstall" Guid="{5BAD46DE-D6AB-42D0-A13E-2407F8FBC97B}" >
        <File Id="filE617B0B38D366E756290A5B22F2660C4" KeyPath="yes" TrueType="no" Source="$(var.BaseDir)\bin\ComSrv.dll" />
      </Component>
    </Directory>

  .
  .
  .
  .
   </Directory>
 </Directory>

我是这个MSBuild和Wix的新手。任何人都可以指出我的剧本中有什么问题。

1 个答案:

答案 0 :(得分:0)

谢谢MikeR。我已经包含了这些文件。但我使用的属性名称(PostHarvestIncludes)拼写不正确。它解决了。