Referencing Properties that contain free form XML

If you have a property group with a property that contains free form XML and you want to reference the value, of say, OutputPath, what is the syntax for doing so?

$(ConfigOptions) gives you the entire XML string, as you would expect. I'd like to get to the CodePath within $(ConfigOptions). I played around with a few variations, but none seemed to work. Are free form XML properties only intended for logging and tasks that actually know how to parse the XML string contained in the top node?

Thanks for any input you can provide.

<PropertyGroup>
<Config
Options>
<
OutputPath>t:\test5\</OutputPath>
<
CodePath>C:\code\</CodePath>
</ConfigOptions>
</PropertyGroup>

[1555 byte] By [Gerhardo] at [2008-2-13]
# 1
in NAnt you could easily use XmlPeek, but I bet you could wrtite MSBuild function , may be somekind of XPath. then passing the Xml faragement to it.
erymuzuan at 2007-9-8 > top of Msdn Tech,Visual Studio,Visual Studio MSBuild...
# 2

Thanks. I just wanted to check if there was a built-in way to access child properties without having to write a separate task for it.

Gerhardo at 2007-9-8 > top of Msdn Tech,Visual Studio,Visual Studio MSBuild...
# 3
There's not any built-in way. There's no official concept of "child properties" although you can certainly write a task to access them as you say.

You may find it easier to use regular properties. Or possibly items, since items can have arbitrary metadata something like "child properties".

Could you tell us why child properties are useful?

DanMoseley at 2007-9-8 > top of Msdn Tech,Visual Studio,Visual Studio MSBuild...
# 4
Thanks for the clarification Dan. Your help documentation pointed out that free-form XML is possible and actually provided a sample. Thus, I thought there might be a built-in way to reference them.

We use MSBuild to create a master build file of solutions. While Visual Studio is fine to use as an editor on a project basis, it will not provide a GUI to edit custom properties that you may want to add that don't relate to a project itself. You can certainly use it to edit the XML directly. Eventually, we will probably end up writing a little editor for our master build file that will make it easier for the build engineer to change custom properties and select a list of targets to build. That is one use where I could see the benefit of child objects. Your editor could then only list out properties nested within a <PropertyGroup><CustomProperties><Property1><Property2></CustomProperties></PropertyGroup>
scenario and ignore other properties. Alternatively, it would be nice to be able to attach a user defined attribute to a property group. That would also allow you to flag certain properties as visible/invisible to your own editor. If that were possible, I wouldn't even bother with freeform XML. Right now, the schema validation fails if you try to add a Name or other attribute to a PropertyGroup.

To make a long story short, what I would really like is the ability to flag properties with additional itemdata, the same way you can flag itemlists with metadata.

I realize that there is a separate element called <Extension> or somethink like that which is ignored by MSBuild and is designed to add functionality for a custom editor. While I could add some custom properties here, it still wouldn't let me identify a PropertyGroup which I want my editor to read in if I also want that propertyGroup to be visible to MSBuild. I could only identify property groups by their ordinals and say, hey editor, read in the first, the third and the fourth propertygroup but skip everything else. That isn't very maintainable, however.

Gerhardo at 2007-9-8 > top of Msdn Tech,Visual Studio,Visual Studio MSBuild...

Visual Studio

Site Classified