How do I work with spaces in my wix source path?

godseyeview picture godseyeview · Nov 28, 2009 · Viewed 8.2k times · Source

wxs file the File tag Source attribute; the path has a space in it.

<File Id="_uploads.UserImport.EDS_UserImport.xls" Name="EDS_UserImport.xls" Source="C:\Documents and Settings\kle\Desktop\OspreyMSIGenerator\OspreyMSIGenerator\Published\EDSContainer\uploads\UserImport\EDS_UserImport.xls"></File>

I get this error

candle.exe : error CNDL0103 : The system cannot find the file 'and' with type 'Source'.

I can't be sure that my paths won't have spaces in it. How do I support spaces in the Source path?

Answer

Wim Coenen picture Wim Coenen · Nov 28, 2009

Try upgrading to the latest stable wix release. I tested this with Wix 3.0.5419.0 and file paths with spaces are accepted without errors.

On a related note: File elements should not contain absolute paths like in your example, because you would only be able to build the setup on a single developer's PC. Use paths relative to the location of the wxs file instead, like this:

<File Source="..\bin\foo.exe" />

Or make use of a variable that contains the location of the files like this:

<File Source="$(var.BinFolder)foo.exe" />

You can then pass the location of the bin folder by invoking candle like this:

candle.exe -dBinFolder=c:\someFolder\bin\ foo.wxs

edit: as shown by Rob in his own answer, you can also use the light.exe -b switch to specify one or more base directories where the files to install can be found.