문제

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.

도움이 되었습니까?

해결책

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>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top