Your sample code is almost correct; it just needs a slight change to the usage of the XmlFile task. The call to XmlFile ReadAttribute should declare Value as the task's output. To do this, add the Output element to the task declaration, set to the TaskParameter
value to "Value" and set the PropertyName
value to "ReleaseVersion", similar to the following:
<MSBuild.ExtensionPack.Xml.XmlFile
TaskAction="ReadAttribute"
File="[example-path-to-app-config]"
XPath="/configuration/system.diagnostics/switches/add[@name='ReleaseVersion']/@value">
<Output TaskParameter="Value" PropertyName="ReleaseVersion" />
<MSBuild.ExtensionPack.Xml.XmlFile>
After making the change, the attribute value should be found/read by the task, assuming your ToolsVersion is set to the version needed by your particular implementation of MSBuild Extension Pack