Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WiX Relative Path to the Source File

Tags:

wix

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.

like image 558
Christian Sauer Avatar asked Oct 19 '12 11:10

Christian Sauer


People also ask

What is relative path in file management?

A relative path is a path that describes the location of a file or folder in relative to the current working directory. It can be best used to refer to websites that are located on the same domain, ideally on certain sections of websites in which the documents never change relationships to each other.

What is relative and absolute file path?

An absolute path is defined as specifying the location of a file or directory from the root directory(/). In other words,we can say that an absolute path is a complete path from start of actual file system from / directory. Relative path. Relative path is defined as the path related to the present working directly(pwd) ...


2 Answers

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.

like image 140
BryanJ Avatar answered Oct 08 '22 04:10

BryanJ


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.

like image 30
Christopher Painter Avatar answered Oct 08 '22 05:10

Christopher Painter