6

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?

durron597
  • 31,968
  • 17
  • 99
  • 158
godseyeview
  • 163
  • 2
  • 11

2 Answers2

6

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.

Wim Coenen
  • 66,094
  • 13
  • 157
  • 251
5

@wcoenen provides one mechanism. However, I prefer to use the light.exe -b switch. Then your code can look like:

<File Id="_uploads.UserImport.EDS_UserImport.xls" Name="EDS_UserImport.xls" Source="SourceDir\Published\EDSContainer\uploads\UserImport\EDS_UserImport.xls"></File>

and your command-line to light.exe would have:

-b "C:\Documents and Settings\kle\Desktop\OspreyMSIGenerator\OspreyMSIGenerator"

You can have multiple -b switches and greatly reduce the complexity of your Source attribute.

Also, the File/@Id and File/@Name can be left off if you are fine with them defaulting to the file name (in this case, "EDS_UserImport.xls").

Rob Mensching
  • 33,834
  • 5
  • 90
  • 130
  • 1
    +1, makes everything much less complex. Unfortunately the WiX documentation doesn't appear to explain the link between using -b for light and using "SourceDir" in File/@Source. – saschabeaumont Nov 29 '09 at 22:47
  • I am really confused about "SourceDir" now, as apparently it has 3 different meanings: 1) magic value that you have to use in `` 2) Windows installer property that points to the folder containing the installation package 3) Special value set with `light.exe -b` that you can use as "". Argh! – Wim Coenen Nov 30 '09 at 15:59
  • 1
    The first two are the same thing. The third option uses SourceDir because the Source inherits it's values from the parent Directory elements and the File/@Name. A lot of people just got in the habit of always specifying the File/@Source instead of using the default. – Rob Mensching Dec 04 '09 at 05:21
  • In Visual Studio 2010, your sample above doesn't work. Placing in the WIX project linker throws: "Your file or directory path '" ... cannot contain a quote. Quotes are often accidentally introduced when trying to refer to a directory path with spaces in it, such as "C:\Out Directory\". The correct representation for that path is: "C:\Out Directory\\" But updating any path breaks with "\\" does not work. It instead throws anerror. This also prevents the use of VS macros such as $(SolutionDir) if the Solution Directory has spaces. Thoughts? – TheHolyTerrah Aug 20 '12 at 22:42
  • Switching from File/@Id to File/@Name solved my issue. I had space in the file name that I was using as file id. – upizs Sep 20 '22 at 08:50