WiX is an XML/XSD abstraction of the underlying Windows Installer database. This database is relational and has such tables as Feature, FetaureComponent, Component, Directory and File. Each of these tables has Primary Key and Foreign Key Columns. For Example
Feature<->FeatureComponent<->Component
Directory<->Component<->File
A directory can have more then one component but a component can only belong to one directory. Same thing can be said for components and files. Therefore in WiX the Directory element is a parent element of the Component element and the Component Element is the parent of a File element. WiX transforms these into PK FK relationships at build time. MSBuild merely calls the WiX compiler tools (candle (the source of your 'CNDL0005' error), light) and MSBuild doesn't know anything about this directly.
A feature can contain more then one component and a component can belong to more then one feature (many to many join). In this case WiX created the Feature <-> ComponentRef relationship.
The example you cite shows the elements in the correct relationship. You just aren't assembling it correctly. The Wix.chm in your startmenu has help topics for each element and lists which elements can be the parent, which can be a child and has a link to the related Windows Installer database table that the element represents.