1

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?

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Yar
  • 321
  • 1
  • 17
  • Yes, **`src`** is deprecated in favor of **`Source`** for [**File Elements**](http://wixtoolset.org/documentation/manual/v3/xsd/wix/file.html) (towards bottom). As to **`Build.xml`**, is that an Ant build script? Are you using Visual Studio, Eclipse, or something else? – Stein Åsmul Sep 04 '18 at 23:10
  • You can add an answer from yourself and set it as accepted. So whoever has a similar issue can find it. – Stein Åsmul Sep 05 '18 at 17:25

1 Answers1

0

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");
FortyTwo
  • 2,414
  • 3
  • 22
  • 33
Yar
  • 321
  • 1
  • 17