Take a closer look at the answer you posted as example; you can't have a WebVirtualDir as a direct child of a Directory, you are missing a Component node between them:
<Directory Id="WebApplicationFolder" Name="MyWebApp">
<Component Id="IIS.Component" Guid="YOUR-GUID-HERE" KeyPath="yes">
<iis:WebVirtualDir Id="ProductVirtualDirectory" Alias="foo" Directory="WEBDIRECTORY" WebSite="DefaultWebSite">
<iis:WebApplication Id="ERIC6_Deploy" Name="Web Application 1"/>
</iis:WebVirtualDir>
</Component>
</Directory>
Remember to replace YOUR-GUID-HERE with a GUID generated by yourself!