1

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:

The system cannot find the file '......\Bin\Debug\PSALERTSScheduleServer.exe'.

I have checked and the file PSALERTSScheduleServer.exe is definitely in the specified relative folder.

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:

 <?xml version="1.0" encoding="UTF-8"?>
 <?define SourceDir = "..\..\..\Bin\Debug" ?>
 <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"  xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
 <Product Id="*" Name="PSALERTSScheduleServerProduct" Language="1033" Version="5.3.0.8" Manufacturer="SP Energy Networks" UpgradeCode="a3baddfc-0965-47ed-a30f-be5eae7bc2df">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
    <MediaTemplate />

    <Feature Id="ProductFeature" Title="PSALERTS ScheduleServer 2018" Level="1">
  <ComponentRef Id="cmpDirScheduleServer" />
  <ComponentRef Id="cmpScheduleServerExe" />
  <ComponentRef Id="cmpScheduleServerPdb" />
    </Feature>
</Product>

<Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder">
            <Directory Id="INSTALLFOLDER" Name="PSALERTSScheduleServerProduct" />
        </Directory>
    </Directory>
</Fragment>

<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
  <!-- The following section deals with the deployment of the program, config and related data files-->
  <Directory Id="ProgramFilesFolder">
    <Directory Id="dirSPEnergyNetworks" Name="SP Energy Networks">
      <Directory Id="dirPSALERTS" Name="PSALERTS">
        <Directory Id="dirScheduleServer" Name="PSALERTS Schedule Server">
          <Component Id="cmpDirScheduleServer" Guid="{a valid guid}" KeyPath="yes">
            <CreateFolder Directory="dirScheduleServer" />
            <RemoveFile Id="PurgeScheduleServer" Name="*.*" On="uninstall" />
            <RemoveFolder Id="idDirScheduleServer" On="uninstall" Directory="dirScheduleServer" />
          </Component>

          <Component Id="cmpScheduleServerExe" Guid="{a valid guid}">
            <File Id="filScheduleServerExe"
                  KeyPath="yes"
                  Source="$(var.SourceDir)\PSALERTSScheduleServer.exe"
              />
            <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">
              <util:PermissionEx
                        User="Everyone"
                        ServicePauseContinue="yes"
                        ServiceQueryStatus="yes"
                        ServiceStart="yes"
                        ServiceStop="yes"
                        ServiceUserDefinedControl="yes"
                                  />
            </ServiceInstall>
            <!-- <ServiceControl 
                              Id="cmpScheduleServerExe" 
                              Start="install" Stop="both" 
                              Remove="uninstall" 
                              Name="psaschdsrvr2018" 
                              Wait="yes" 
                   />-->
            <RemoveRegistryKey Id="RemoveScheduleServerRegKey" Root="HKLM" Key="SOFTWARE\SP Energy Networks\PSALERTS\Schedule Server" Action="removeOnUninstall" />
          </Component>

          <Component Id="cmpScheduleServerPdb" Guid="{a valid guid}">
            <File Id="filScheduleServerPdb" KeyPath="yes" Source="$(var.SourceDir)\PSALERTSScheduleServer.pdb" />
          </Component>
        </Directory>
      </Directory>
    </Directory>
  </Directory>
</Directory>              

Paul Johnson
  • 213
  • 3
  • 14
  • NOTE: I have since replaced the relative path reference with the literal path and it is still not working. – Paul Johnson Apr 14 '20 at 11:56
  • Can't look at this now, but I would comment out everything and add back one file, hard code the path to absolute (C:\Full Path Here\File.exe) just to get a heartbeat compiling - sort of obvious I guess. Just off the top of my head to verify there are no other errors. – Stein Åsmul Apr 15 '20 at 02:03
  • I did something strange here, I can't quite recall what I was up to :-) - but maybe have a look: [SO answer](https://stackoverflow.com/a/54766353/129130) and the associated [WiX sample source](https://github.com/glytzhkof/all/blob/master/CompilerVariables.wxs). The $(sys.SOURCEFILEDIR) should give you the folder where the WiX source file is located. [Preprocessor](https://wixtoolset.org/documentation/manual/v3/overview/preprocessor.html). Why did I not just use relative path? There was a reason - I don't remember. I would use somenthing other than SourceDir, for example: $(var.MyReleasePath) – Stein Åsmul Apr 15 '20 at 02:03
  • [Throwing in this link too](https://stackoverflow.com/a/56067145/129130). Sorry about the messy "spamming". Just want to lob you some links in case nobody else answers. – Stein Åsmul Apr 15 '20 at 02:14

0 Answers0