title: How Do I Get WiX Project to Pick Up Executable
body: <p>I have encountered an issue with a VS2017 Project that I am building.  For some reason the WiX project is unable to locate the executable and related files.  I get the following error message:</p>
  
  <p>The system cannot find the file '......\Bin\Debug\PSALERTSScheduleServer.exe'.</p>
  
  <p>I have checked and the file PSALERTSScheduleServer.exe is definitely in the specified relative folder.</p>
  
  <p>I have used the technique of a defined variable to hold the location of the executable in WiX projects successfully for a number of different projects over the years, however this one is 'bucking the trend'
  I am using WiX 3.11.  Here is the product.wsx file for the project:</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
   &lt;?define SourceDir = "..\..\..\Bin\Debug" ?&gt;
   &lt;Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"  xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"&gt;
   &lt;Product Id="*" Name="PSALERTSScheduleServerProduct" Language="1033" Version="5.3.0.8" Manufacturer="SP Energy Networks" UpgradeCode="a3baddfc-0965-47ed-a30f-be5eae7bc2df"&gt;
      &lt;Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" /&gt;
  
      &lt;MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /&gt;
      &lt;MediaTemplate /&gt;
  
      &lt;Feature Id="ProductFeature" Title="PSALERTS ScheduleServer 2018" Level="1"&gt;
    &lt;ComponentRef Id="cmpDirScheduleServer" /&gt;
    &lt;ComponentRef Id="cmpScheduleServerExe" /&gt;
    &lt;ComponentRef Id="cmpScheduleServerPdb" /&gt;
      &lt;/Feature&gt;
  &lt;/Product&gt;
  
  &lt;Fragment&gt;
      &lt;Directory Id="TARGETDIR" Name="SourceDir"&gt;
          &lt;Directory Id="ProgramFilesFolder"&gt;
              &lt;Directory Id="INSTALLFOLDER" Name="PSALERTSScheduleServerProduct" /&gt;
          &lt;/Directory&gt;
      &lt;/Directory&gt;
  &lt;/Fragment&gt;
  
  &lt;Fragment&gt;
  &lt;Directory Id="TARGETDIR" Name="SourceDir"&gt;
    &lt;!-- The following section deals with the deployment of the program, config and related data files--&gt;
    &lt;Directory Id="ProgramFilesFolder"&gt;
      &lt;Directory Id="dirSPEnergyNetworks" Name="SP Energy Networks"&gt;
        &lt;Directory Id="dirPSALERTS" Name="PSALERTS"&gt;
          &lt;Directory Id="dirScheduleServer" Name="PSALERTS Schedule Server"&gt;
            &lt;Component Id="cmpDirScheduleServer" Guid="{a valid guid}" KeyPath="yes"&gt;
              &lt;CreateFolder Directory="dirScheduleServer" /&gt;
              &lt;RemoveFile Id="PurgeScheduleServer" Name="*.*" On="uninstall" /&gt;
              &lt;RemoveFolder Id="idDirScheduleServer" On="uninstall" Directory="dirScheduleServer" /&gt;
            &lt;/Component&gt;
  
            &lt;Component Id="cmpScheduleServerExe" Guid="{a valid guid}"&gt;
              &lt;File Id="filScheduleServerExe"
                    KeyPath="yes"
                    Source="$(var.SourceDir)\PSALERTSScheduleServer.exe"
                /&gt;
              &lt;ServiceInstall Id="cmpScheduleServerExe"
                                  Type="ownProcess"
                                  Name="psaschdsrvr2018"
                                  DisplayName="PSALERTS Schedule Server 2018"
                                  Description="For automatic generation and delivery of PSALERTS reports."
                                  Start="demand"
                                  Account="LocalSystem"
                                  ErrorControl="normal"&gt;
                &lt;util:PermissionEx
                          User="Everyone"
                          ServicePauseContinue="yes"
                          ServiceQueryStatus="yes"
                          ServiceStart="yes"
                          ServiceStop="yes"
                          ServiceUserDefinedControl="yes"
                                    /&gt;
              &lt;/ServiceInstall&gt;
              &lt;!-- &lt;ServiceControl 
                                Id="cmpScheduleServerExe" 
                                Start="install" Stop="both" 
                                Remove="uninstall" 
                                Name="psaschdsrvr2018" 
                                Wait="yes" 
                     /&gt;--&gt;
              &lt;RemoveRegistryKey Id="RemoveScheduleServerRegKey" Root="HKLM" Key="SOFTWARE\SP Energy Networks\PSALERTS\Schedule Server" Action="removeOnUninstall" /&gt;
            &lt;/Component&gt;
  
            &lt;Component Id="cmpScheduleServerPdb" Guid="{a valid guid}"&gt;
              &lt;File Id="filScheduleServerPdb" KeyPath="yes" Source="$(var.SourceDir)\PSALERTSScheduleServer.pdb" /&gt;
            &lt;/Component&gt;
          &lt;/Directory&gt;
        &lt;/Directory&gt;
      &lt;/Directory&gt;
    &lt;/Directory&gt;
  &lt;/Directory&gt;              
  </code></pre>
  
  <p></p>
  
  <p></p>