[wix-users] `File/@Name` doesn't work as expected when nested under `Component/@Directory`

Rob Mensching rob at firegiant.com
Fri May 1 09:10:21 PDT 2020


Your confusion is understandable. The behavior you are seeing is the design although one could absolutely argue for the design you expected. The linker will follow references to create the target directory tree but that does not affect the build time source location for the files. Build time source resolution is passed down only via the immediate XML hierarchy.

---
Short replies here. Complete answers here: https://www.firegiant.com/services/

-----Original Message-----
From: wix-users <wix-users-bounces at lists.wixtoolset.org> On Behalf Of Armen Michaeli via wix-users
Sent: Friday, May 1, 2020 5:32 AM
To: wix-users at lists.wixtoolset.org
Cc: Armen Michaeli <armen.michaeli at gmail.com>
Subject: Re: [wix-users] `File/@Name` doesn't work as expected when nested under `Component/@Directory`

Apologies, there is a typo in the earlier message: the error message [with the second snippet] isn't "LGHT0113", it is LGHT0103: "The system cannot find the file 'README.txt'."

The file can otherwise be accessed just fine with the first snippet, for comparison.

On Fri, May 1, 2020 at 2:23 PM Armen Michaeli <armen.michaeli at gmail.com>
wrote:

> From what I understand, per the "How To: Specify source files" page 
> <https://wixtoolset.org/documentation/manual/v3/howtos/general/specify
> ing_source_files.html> and as briefly touched upon by the "Component 
> Element"
> <https://wixtoolset.org/documentation/manual/v3/xsd/wix/component.html
> >
> and "File Element"
> <https://wixtoolset.org/documentation/manual/v3/xsd/wix/file.html> 
> pages, when a file is specified using the File/@Name attribute, it is 
> effectively accessed by name relative to the directory of the 
> component the file is part of. The component's directory, in turn, is 
> ideally understood (by me) to be either the directory specified by the 
> nearest ancestor Directory element, *or* by the Component/@Directory attribute, if present.
>
> Needless to say, the following works as expected:
>
> <Directory Id="INSTALLDIR" Name="Foobar" FileSource="!(wix.SOURCEDIR)">
>     <Component>
>         <File Name="README.txt" />
>     </Component>
> </Directory>
>
> The following, however, does not:
>
> <Directory Id="INSTALLDIR" Name="Foobar" FileSource="!(wix.SOURCEDIR)" 
> /> <Feature>
>     <Component Directory="INSTALLDIR">
>         <File Name="README.txt" />
>     </Component>
> </Feature>
>
> I am surprised. Is the behaviour intended by design, an omission or 
> something else? The "How To: Specify source files" page 
> <https://wixtoolset.org/documentation/manual/v3/howtos/general/specify
> ing_source_files.html>
> says:
>
> When you use the File/@Name attribute and don't use the File/@Source 
> attribute, the compiler constructs an implicit path to the file based 
> on the file's parent component directory plus the name you supply.
>
> In case of the second snippet above, the component's directory *is
> specified* (INSTALLDIR), is it not? Why can't the file be found? It 
> seems that WiX only actually wants to use the directory based on 
> element parent-child relationship, not the one created by the 
> Component/@Directory attribute value.
>
> I am using candle.exe and light.exe, it is the linker/binder (the 
> latter) that produces the LGHT0113 error.
>
> WiX version 3.11.2.4516
> .NET version 3.1.201 (dotnet --version)
>

____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/



More information about the wix-users mailing list