33

I have a simple Solution for my Project, which works well. But I am unable to grasp how to make the Source paths relative. Can somebody help me?

  <Component Id="Bla.exe" Guid="*">
    <File Id="Bla.exe" Source="D:\Projects\Bla\Bla\bin\Debug\Bla.exe" KeyPath="yes" Checksum="yes"/>
  </Component>

How can I make the Path relative to the Wix Solution? WiX and all necessary files are in the same Solution.

1
  • 1
    So, roughly ten years later I have the misfortune to work with wix again. And it's documentation is still shit. Mar 28 at 12:47

2 Answers 2

71

You can use the relative path like so:

    <File Id="Bla.exe" Source="..\bin\Debug\Bla.exe" KeyPath="yes" Checksum="yes"/>

OR

You can add a configuration file to your project to define common variables. To do so, add a new "WiX Include" file to your project, call it config.wxi. Then in your include file, you can define a SourceDir variable like so:

<?xml version="1.0" encoding="utf-8"?>
<Include>
  <?define SourceDir = "D:\Projects\Bla\Bla\bin\Debug" ?>
</Include>

Now in your .wxs file, you can add a reference to the config file at the top, ex:

<?xml version="1.0" encoding="UTF-8"?>
 <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
 <?include "config.wxi"?>

Then just reference your SourceDir variable like so:

<File Id="Bla.exe" Source="$(var.SourceDir)\Bla.exe" KeyPath="yes" Checksum="yes"/>

Also, there are some built in WiX project variables that you may use.

3
  • That looks great! Thank you! Is there a possibillity to use different values for var.Sourcedir - depending on debug or release Installation? Oct 19, 2012 at 11:58
  • 1
    See the link I added. There are built in project variables that should help.
    – BryanJ
    Oct 19, 2012 at 12:07
  • In the context of my related question, I tried this and found that the include file will not work for my situation. Any form of setting variables does not make the variable available to the dependency project. However, the project variables that you linked to do look like they may work for my purposes, because they are stable independent of the contexts of other projects. Thank you for including that link. Feb 10, 2014 at 22:54
2

There are many ways to do this but personally what I like to do is put my application installer projects in different solutions. I build the application solution first and use postbuild commands to publish the content to a deploy folder.

In my installer projects I set $(var.SourceDir)="..\deploy" and then $(var.SourceDir)\foo.exe for a source path.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.