title: Copy files with Condition not copied actually in MSBuild
body: <p>I am using WIX with MSBuild. I am trying to copy a com library and a .ttf file to two different locations and I want to register the com library using WIX. When I run it using Visual Build Pro I don't see any errors or warnings and I can see the copy scripts being added to setup files. But the files are not copied to the specified directory after installing the setup.</p>
  
  <p>Build.msbuild with <code>&lt;Target&gt;</code> as below:</p>
  
  <pre><code>&lt;Target Name="Setup"&gt;
  &lt;!-- Setup the source directory structure as it should appear on the target machine --&gt;
  
  &lt;ItemGroup&gt;
    &lt;DeployFiles Include="$(Includes)" Exclude="$(Excludes)" /&gt;
    &lt;PostHarvestFiles Include="$(PostHarvestIncludes)" Exclude="$(PostHarvestExcludes)" /&gt;
  &lt;/ItemGroup&gt;
  
  &lt;MakeDir Directories="$(OutputDir)" /&gt;
  &lt;MakeDir Directories="$(FinalOutputDir)" /&gt;
  &lt;MakeDir Directories="$(FilesToInstallDir)" /&gt;
  
  &lt;!-- Harvest the newly created directory structure for the MSI --&gt;
  &lt;Copy SourceFiles="@(DeployFiles)" DestinationFiles="@(DeployFiles-&gt;'$(FilesToInstallDir)\%(RecursiveDir)%(Filename)%(Extension)')" /&gt;    
  &lt;Exec Command='$(BuildToolsDir)\Wix\heat.exe dir "$(FilesToInstallDir)" -dr INSTALLDIR -gg -cg FilesToInstall -sfrag -srd -sreg -out "$(MSBuildThisFileDirectory)Files.wxs" -var var.BaseDir' /&gt;
  
   &lt;Copy Condition="'%(Extension)' == '.ttf'" SourceFiles="@(PostHarvestFiles)"  DestinationFiles="@(PostHarvestFiles-&gt;'$(FilesToInstallDir)\%(RecursiveDir)%(Filename)%(Extension)')" /&gt;
  
  &lt;!-- Harvest the old renderer DLL. This is a COM object and needs special handling --&gt;
  &lt;Copy Condition="'%(Extension)' == '.dll'" SourceFiles="@(PostHarvestFiles)" DestinationFiles="@(PostHarvestFiles-&gt;'$(ComFilesToInstallDir)\%(RecursiveDir)%(Filename)%(Extension)')" /&gt;
  &lt;Exec Command='$(BuildToolsDir)\Wix\heat.exe file "$(ComFilesToInstallDir)\ComSrv.dll" -dr COMINSTALLDIR -ag -cg COMObjectsToInstall -out "$(MSBuildThisFileDirectory)COMDlls.wxs" -var var.ExternalsDir' /&gt;
  &lt;/Target&gt;
  
  
   &lt;Target Name="CompileWix" DependsOnTargets="Setup"&gt;
   &lt;!--  Create the Wix object files for linking in the next task  --&gt;
  &lt;ItemGroup&gt;
    &lt;WixFiles Include="$(SourceDir)\Installer-Website\*.wxs" /&gt;
  &lt;/ItemGroup&gt;
  
  &lt;!-- Compile the Wix object files --&gt;
  &lt;Exec Command="$(BuildToolsDir)\Wix\candle.exe -dBaseDir=&amp;quot;$(FilesToInstallDir)&amp;quot; -dBuildToolsDir=&amp;quot;$(BuildToolsDir)&amp;quot; -dExternalsDir=&amp;quot;$(SourceDir)\ExternalAssembly&amp;quot; -dFinalVersion=$(FinalVersion) -ext WiXNetFxExtension -ext WixIisExtension -out $(OutputDir)\ @(WixFiles-&gt;'%(Filename)% (Extension)',' ')" /&gt;
  &lt;/Target&gt;
  
  
  &lt;Target Name="BuildMsi" DependsOnTargets="CompileWix"&gt;
  &lt;!--   Link the Wix object files into the final MSI --&gt;
  &lt;ItemGroup&gt;
    &lt;WixObjectFiles Include="$(OutputDir)\*.wixobj" /&gt;
  &lt;/ItemGroup&gt;
  
  &lt;!--  Link the Wix object files into the final MSI  --&gt;
  &lt;Exec Command="$(BuildToolsDir)\Wix\light.exe -cultures:en-us -loc      &amp;quot;$(MSBuildThisFileDirectory)WebAppInstallDlg_en-us.wxl&amp;quot; -sice:ICE17 -sice:ICE38 -sice:ICE43 -sice:ICE57 -sice:ICE64 -ext WixUIExtension -ext WiXNetFxExtension -ext WixIisExtension -out $(OutputDir)\$(MsiName) @(WixObjectFiles-&gt;'%(FullPath)',' ')" /&gt;
  &lt;Copy SourceFiles="$(OutputDir)\$(MsiName)" DestinationFolder="$(FinalOutputDir)" /&gt;
  
   &lt;/Target&gt;
  </code></pre>
  
  <p>Product.wxs file with Directory as below:</p>
  
  <pre><code> &lt;Directory Id="TARGETDIR" Name="SourceDir"&gt;
    &lt;Directory Id="INSTALLDIR" Name="$(var.BaseProductName)"&gt;
      &lt;Directory Id="FontsFolder"&gt;
        &lt;Component Id="cmp_FontsToInstall" Guid="{C286A08B-28CB-4A62-9BF8-833A6B141CB4}"&gt;
          &lt;File Id="fil82FBA6D3A96B47C48C72FA2F03739758" KeyPath="yes" TrueType="yes" Source="$(var.BaseDir)\OOCA.ttf" /&gt;
        &lt;/Component&gt;        
      &lt;/Directory&gt;
  
      &lt;Directory Id="COMINSTALLDIR" &gt;
        &lt;Component Id="COMObjectsToInstall" Guid="{5BAD46DE-D6AB-42D0-A13E-2407F8FBC97B}" &gt;
          &lt;File Id="filE617B0B38D366E756290A5B22F2660C4" KeyPath="yes" TrueType="no" Source="$(var.BaseDir)\bin\ComSrv.dll" /&gt;
        &lt;/Component&gt;
      &lt;/Directory&gt;
  
    .
    .
    .
    .
     &lt;/Directory&gt;
   &lt;/Directory&gt;
  </code></pre>
  
  <p>I am new to this MSBuild and Wix. Can any one please point out what was is wrong in my script.</p>