1

I have a C# application which its build targets are x86 or x64. The build output is (for example) ProjectDir/bin/x86|x64/Debug|Release/*

In my *.wxs file I have defined thr following variable

<?define AppTargetPath = "$(var.MyApp.TargetPath)" ?>

Which points to ProjectDir/bin/Debug|Release/app.exe

If I build the installer, it fails because it does not find my app exe

<File Id="AppExe" Source="$(var.AppTargetPath)" KeyPath="yes"/>

If I look on Using Project References and Variables site (http://wixtoolset.org/documentation/manual/v3/votive/votive_project_references.html) I cannot find another variable.

Dominic Jonas
  • 3,671
  • 1
  • 25
  • 55

2 Answers2

0

Maybe try this:

  1. Comment out your existing define.
  2. Add the project building the EXE and your WiX project to the same solution.
  3. Add a reference from the WiX project to the EXE / Binary project.
  4. Try this markup (replace project name "TestConsoleApplication" with yours):

    <Fragment>
      <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
       <Component>
        <File Source="$(var.TestConsoleApplication.TargetPath)" />
       </Component>
      </ComponentGroup>
    </Fragment>
    
  5. Rebuild All.
  6. Toggle Release and Debug builds, then Rebuild All again.

Links:

Stein Åsmul
  • 34,628
  • 23
  • 78
  • 140
  • Thank you for your answer. How can you add the exe to the wix project? I can only reference the whole project. I don't know the exact path of my app, because of its different output path. But I like your "real world example" from your website!! – Dominic Jonas Jan 23 '19 at 07:41
  • The Real-World Example is from Helge Klein. I didn't think you needed to use defines for the paths like you do, you should be able to rely on auto-magic, but if the defines work that's great. – Stein Åsmul Jan 23 '19 at 21:59
0

Actually I solved it by putting together the entire path on top of my wxs file:

<?define AppTargetFileName = "$(var.myApp.TargetFileName)" ?>

<?if $(var.Platform) = x64 ?>
  <?define AppTargetPath = "$(var.myApp.ProjectDir)\bin\x64\$(var.myApp.Configuration)\$(var.AppTargetFileName)" ?>
<?elseif  $(var.Platform) = x86 ?>
  <?define AppTargetPath = "$(var.myApp.ProjectDir)\bin\x86\$(var.myApp.Configuration)\$(var.AppTargetFileName)" ?>
<?else ?>
  <?define AppTargetPath = "$(var.myApp.TargetPath)" ?>
<?endif ?>
Dominic Jonas
  • 3,671
  • 1
  • 25
  • 55