I’m using the MSBuild APIs.
I have a simple ProjectRootElement:
var project = ProjectRootElement.Create(XmlReader.Create(new StringReader(input)));
Then, I iterate over all PropertyGroup
s:
foreach (ProjectPropertyGroupElement group in project.PropertyGroups)
{
Console.WriteLine(group.Condition);
}
When I access the .Condition
property of ProjectPropertyGroupElement
, I’m assuming that this will return a boolean, which specifies the evaluated value of the condition.
For example, I have a PropertyGroup here:
<PropertyGroup Condition="$(UpdateVersion) >= $(CurrentVersion) and $(Status.ToLower()) == 'newupdate'">
<UpdateVersion>158</UpdateVersion>
<CurrentVersion>144</CurrentVersion>
<Status>NewUpdate</Status>
<Reporting>
<UpdateAvailable />
</Reporting>
</PropertyGroup>
When I access the .Condition
property, I assume that this will evaluate the Condition
attribute of PropertyGroup
and return the result as a boolean. The condition attribute checks if ‘UpdateVersion’ >= ‘CurrentVersion’ and ‘Status’ equals to ‘NewUpdate’, which should return true. Instead, the Condition property returns the raw condition value:
$(UpdateVersion) >= $(CurrentVersion) and $(Status.ToLower()) == 'newupdate'
Is there a way to evaluate the .Condition
property of ProjectPropertyGroupElement into a boolean?
1