Reputation: 1
I have a problem to get data from msbuild file where I have something like this:
<Application Include="ABC">
...
/Application>
<Application Include="XYZ">
<Parameters>
<Param name="param1">valueOfIt</Param>
<Param name="param2">value2</Param>
</Parameters>
</Application>
I can rad all <Param>
in <Parameters>
like this:
<FindInList CaseSensitive="false" List="@(Application)" ItemSpecToFind="$(Application)">
<Output TaskParameter="ItemFound" ItemName="Parameters"/>
</FindInList>
then <Message Text="@(Parameters->'%(Parameters)'))"/>
displays an xml with all <Param>
. I need to create a property with the value from param1... How to parse this??
Upvotes: 0
Views: 1713
Reputation: 761
If you are interested just in static ItemGroup you can use XmlPeek (this answer is inspired by)
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<ItemGroup>
<Application Include="ABC">
</Application>
<Application Include="XYZ">
<Parameters>
<Param name="param1">valueOfIt</Param>
<Param name="param2">value2</Param>
</Parameters>
</Application>
</ItemGroup>
<Target Name="Sample">
<XmlPeek Namespaces="<Namespace Prefix='msb' Uri='http://schemas.microsoft.com/developer/msbuild/2003'/>"
XmlInputPath="$(MSBuildProjectFile)"
Query="/msb:Project/msb:ItemGroup/msb:Application/msb:Parameters/msb:Param[@name='param1']/text()">
<Output TaskParameter="Result" PropertyName="PeekedParam1" />
</XmlPeek>
<Message Text="'$(PeekedParam1)'" />
</Target>
</Project>
Upvotes: 1