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

Armen Michaeli armen.michaeli at gmail.com
Fri May 1 05:32:24 PDT 2020


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/specifying_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/specifying_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)
>



More information about the wix-users mailing list