Question

Is there a neat way to create "boolean" properties to use in MSBuild? I can evaluate the expression inside a Condition attribute, but not inside the Value attribute of a CreateProperty task.

I'd like to do something like this:

<CreateProperty Value="'$(IncludeInBuild)'=='' OR 
    '$([System.Text.RegularExpressions.Regex]::IsMatch($(MSBuildProjectFullPath), 
    $(IncludeInBuild)'=='True'">
    <Output TaskParameter="Value" PropertyName="MatchesInclude" />
</CreateProperty>

What that gives me is not True or False, but

''=='' OR '$([System.Text...

Can I evaluate a boolean expression and set a property with the result? My workaround now is just to repeat the expression in Condition attributes wherever I need it.

Était-ce utile?

La solution

How about creating a default property 'false' with a condition to assign true if the condition passes?

<PropertyGroup>
    <MatchesInclude>false</MatchesInclude>
    <MatchesInclude Condition="'$(IncludeInBuild)'=='' OR 
    '$([System.Text.RegularExpressions.Regex]::IsMatch($(MSBuildProjectFullPath), 
    $(IncludeInBuild)'=='True'">true</MatchesInclude>
</PropertyGroup>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top