Search code examples
wixwix3.5wix3wix3.7wix3.8

wix - error CNDL0004: The file element contains an unexpected attribute "src" when running from the command line


When I run the below command from the command line for the WIx installer after migrated from version 2.0 to 4.0

E:\Code\PCPE\builder>ant -v -f Build.xml -Dlabel =.001 install

I am getting the below error:

error CNDL0004: The file element contains an unexpected attribute "src"

I am seeing the error in EMR_COMMON.wxs file in line no 4.

  1. Fragment>
  2. DirectoryRef Id="INSTALLDIR">
  3. Component Id="component_COMMON" Guid="" DiskId="1">
  4. File Id="file0_COMMON" Name="apcrun.exe" src="E:\Code\apcrun.exe"/>

I am thinking that "src" attribute is deprecated and it should be replaced with some other attribute.

But here i can't directly replace the "src" attribute in EMR_COMMON.wxs file bcz it is generating from "Build.xml".

So what are the attributes i need to change in "Build.xml" file to get the appropriate attribute inplace of "src" in "EMR_COMMON.wxs" file?


Solution

  • I resolved the issue. I write the below C# code to replace src attribute name with Source attribute.

    For this first i got the File node list, get the count of the file nodes and then used

    XmlNodeList fileNodeList = compElement.GetElementsByTagName("File"); 
    XmlElement fileElement = (XmlElement)fileNodeList[i]; 
    String srcString = fileElement.GetAttribute("src"); 
    fileElement.SetAttribute("Source", srcString); 
    fileElement.RemoveAttribute("src");