Why doesn't MSBuild ItemGroup conditional work in a global scope

后端 未结 1 673
离开以前
离开以前 2020-12-17 02:11

I\'m desperately curious why I am unable to create an item in a global scope based on a metadata condition which works as expected inside a target. For instance, this works

1条回答
  •  温柔的废话
    2020-12-17 02:39

    The item group condition works outside a target, but batching doesn't (that's the "%" operator). Batching is used when you call a task, and since you can only call a task from inside a target, it makes sense for batching to also only work inside a target.

    You might ask why the item group works inside the target since it's not a task. Prior to MSBuild 3.5, you weren't allowed item groups inside targets at all; you had to call CreateItem instead. In versions 3.5 and 4.0, using item groups that way is allowed, but I think it's just syntactic sugar for calling the CreateItem task, so your condition works because there is a task behind the scenes.

    0 讨论(0)
提交回复
热议问题