title: TFS2012 WIX builds and relative paths
body: <p>I'm setting up CI builds on TFS. A team member developers doesn't like idea of unloading the <strong>.wixproj</strong> file to edit the msbuild definition (because it is 'hidden') and I <em>kind of</em> agree with this.</p>
  
  <p>So he has created a separate <strong>setup.build</strong> file which he calls with:</p>
  
  <pre><code>msbuild /t:Build;PublishWebsite;Harvest;WIX setup.build
  </code></pre>
  
  <p>The contents of which are below:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Project ToolsVersion="4.0" DefaultTargets="Build"
         xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
    &lt;PropertyGroup&gt;
      &lt;WebSiteSource&gt;..\InstoreApplications\&lt;/WebSiteSource&gt;
      &lt;SetupF&gt;..\Setup\&lt;/SetupF&gt;
      &lt;PublishF&gt;publish\&lt;/PublishF&gt;
      &lt;Publish&gt;$(SetupF)$(PublishF)&lt;/Publish&gt;
      &lt;WebSiteContentCode&gt;WebSiteContent.wxs&lt;/WebSiteContentCode&gt;
      &lt;WebSiteContentObject&gt;WebSiteContent.wixobj&lt;/WebSiteContentObject&gt;
      &lt;!--&lt;MsiOut&gt;bin\\Release\\INT SMK Coles Store WebApi 1.0.1.msi&lt;/MsiOut&gt;--&gt;
      &lt;MsiName&gt;INT SMK Instore Applications 1.0.2.msi&lt;/MsiName&gt;
      &lt;MsiOut&gt;bin\Release\$(MsiName)&lt;/MsiOut&gt;
    &lt;/PropertyGroup&gt;
  
    &lt;!-- Defining group of temporary files which is the content of the web site. --&gt;
    &lt;ItemGroup&gt;
      &lt;WebSiteContent Include="$(WebSiteContentCode)" /&gt;
    &lt;/ItemGroup&gt;
  
    &lt;!-- The list of WIX input files --&gt;
    &lt;ItemGroup&gt;
      &lt;WixCode Include="Product.wxs" /&gt;
      &lt;WixCode Include="$(WebSiteContentCode)" /&gt;
      &lt;WixCode Include="WebAPIDlg.wxs" /&gt;
      &lt;WixCode Include="IISConfiguration.wxs" /&gt;
      &lt;WixCode Include="WixUI_InstallDirNoLicense.wxs" /&gt;
    &lt;/ItemGroup&gt;
  
    &lt;!-- The list of WIX after candle files --&gt;
    &lt;ItemGroup&gt;
      &lt;WixObject Include="Product.wixobj" /&gt;
      &lt;WixObject Include="$(WebSiteContentObject)" /&gt;
      &lt;WixObject Include="WebAPIDlg.wixobj" /&gt;
      &lt;WixObject Include="IISConfiguration.wixobj" /&gt;
      &lt;WixObject Include="WixUI_InstallDirNoLicense.wixobj" /&gt;
    &lt;/ItemGroup&gt;
  
    &lt;!-- Define default target with name 'Build' --&gt;
    &lt;Target Name="Build"&gt;
      &lt;!-- Compile whole solution in release mode --&gt;
      &lt;MSBuild
          Projects="..\InstoreApplications.sln"
          Targets="ReBuild"
          Properties="Configuration=Release" /&gt;
    &lt;/Target&gt;
  
    &lt;Target Name="PublishWebsite"&gt;
      &lt;!-- Remove complete publish folder in order to 
               be sure that evrything will be newly compiled --&gt;
      &lt;Message Text="Removing publish directory: $(SetupF)"/&gt;
      &lt;RemoveDir Directories="$(SetupF)" ContinueOnError="false" /&gt;
      &lt;Message Text="Start to publish website" Importance="high" /&gt;
      &lt;MSBuild
          Projects="..\\InstoreApplications\InstoreApplications.csproj"
          Targets="ResolveReferences;_CopyWebApplication"
          Properties="Configuration=Release;WebProjectOutputDir=$(Publish)\;OutDir=$(Publish)bin\;" /&gt;
    &lt;/Target&gt;
    &lt;!-- Define creating installer in another target --&gt;
    &lt;Target Name="Harvest"&gt;
      &lt;!-- Harvest all content of published result --&gt;
      &lt;Exec
          Command='"$(Wix)bin\heat" dir $(Publish) -dr INSTALLDIR -ke -srd -cg ApplicationComponents -var var.publishDir -gg -out $(WebSiteContentCode)'
          ContinueOnError="false"
          WorkingDirectory="." /&gt;
    &lt;/Target&gt;
    &lt;Target Name="WIX"&gt;
      &lt;!--     At last create an installer --&gt;
      &lt;Exec
          Command='"$(Wix)bin\candle" -ext WixIISExtension -ext WixUtilExtension -ext WixSqlExtension -dpublishDir=$(Publish) -dMyWebResourceDir=. @(WixCode, &amp;apos; &amp;apos;)'
          ContinueOnError="false"
          WorkingDirectory="." /&gt;
      &lt;Exec
          Command='"$(Wix)bin\light" -ext WixIISExtension -ext WixUIExtension -ext WixUtilExtension -ext WixSqlExtension -out "$(MsiOut)" @(WixObject, &amp;apos; &amp;apos;)'
          ContinueOnError="false"
          WorkingDirectory="." /&gt;
  
      &lt;!-- A message at the end --&gt;
      &lt;Message Text="Install package has been created." /&gt;
    &lt;/Target&gt;
    &lt;!-- Optional target for deleting temporary files. Usually after build --&gt;
    &lt;Target Name="DeleteTmpFiles"&gt;
      &lt;RemoveDir Directories="$(Publish)" ContinueOnError="false" /&gt;
      &lt;RemoveDir Directories="$(SetupF)" ContinueOnError="false" /&gt;
      &lt;Delete Files="@(WixObject);@(WebSiteContent)" /&gt;
    &lt;/Target&gt;
  
  &lt;/Project&gt;
  </code></pre>
  
  <p>This works absolutely fine on local machine.</p>
  
  <p>For the TFS build I reference the setup.build file directly in the build defination and pass in the: "/t:Build;PublishWebsite;Harvest;WIX" in Advanced>MSBuild Arguments ...this produces a 'success' build however the build is no longer producing an MSI.</p>
  
  <p>I <strong><em>believe</em></strong> the issue is between the HEAT generation of files and WIX picking these files up, note the variables:</p>
  
  <pre><code>&lt;SetupF&gt;..\Setup\&lt;/SetupF&gt;
  &lt;PublishF&gt;publish\&lt;/PublishF&gt;
  &lt;Publish&gt;$(SetupF)$(PublishF)&lt;/Publish&gt;
  </code></pre>
  
  <p>The HEAT command <strong>does</strong> produce a folder with files on the build server, the folder ends up under /src rather than /bin and this is logically the same as building locally</p>
  
  <p>However as the path is relative and I am guessing the WIX candle and/or light commands need their WorkingDirectory changed?...Is there a way to do this and not break the local build and not hardcode the path?</p>