[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:23:56 PDT 2020


>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