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

2019-04-07 18:19发布

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?

2条回答
太酷不给撩
2楼-- · 2019-04-07 18:53

@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 find with them defaulting to the file name (in this case, "EDS_UserImport.xls").

查看更多
三岁会撩人
3楼-- · 2019-04-07 18:59

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.

查看更多
登录 后发表回答