Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create property in MSBuild with result of a boolean expression

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.

like image 779
Rob Avatar asked Sep 20 '13 08:09

Rob


1 Answers

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>
like image 180
Nicodemeus Avatar answered Nov 20 '22 01:11

Nicodemeus