pamidur
pamidur

Reputation: 602

MsBuild condition count items

I want error to be thrown if number of data-items more than one. Why doesn't the following work? How do I code correct expression?

<ItemGroup>
  <Data Include="a"/>
  <Data Include="b"/>
</ItemGroup>

<Error Text="Error!" Condition="@(Data->Count()) &gt; 1" />

ps. msbuild v4.0

Upvotes: 17

Views: 5132

Answers (1)

pamidur
pamidur

Reputation: 602

I've found solution: You want to wrap your expression with the single quotes

<Error Text="Error!" Condition="'@(Data->Count())' &gt; 1" />

Upvotes: 37

Related Questions