Support ItemDefinitionGroup in Choose/When
Steps to reproduce
I am trying to set copy local false in all my projects (outputtype=library)from the Driectory.build.props file in the root folder.
<When Condition=" '$(OutputType)'=='Library' ">
<ItemDefinitionGroup>
<Reference>
<Private>False</Private>
</Reference>
<ProjectReference>
<Private>False</Private>
</ProjectReference>
</ItemDefinitionGroup>
</When>
<When Condition=" '$(OutputType)'=='exe' ">
<ItemDefinitionGroup>
<Reference>
<Private>True</Private>
</Reference>
<ProjectReference>
<Private>True</Private>
</ProjectReference>
</ItemDefinitionGroup>
</When>
should I be able to use conditional constructs this way? I tried above but get an error
The element <ItemDefinitionGroup> beneath element <When> is unrecognized.
Choose/When evidently supports only ItemGroup/PropertyGroup. I don't know why that is, but it's documented.
You'll have to use conditions on the ItemDefinitionGroup instead.
https://github.com/dotnet/msbuild/blob/6033e4c95bcd9fa31ebe9b52462c15521cda8f62/src/Build/Evaluation/ProjectParser.cs#L848-L872 reference the code, under when, only support choose, itemGroup, and PropertyGroup currently.
I don't know why that is, but it's documented.
I think it was just an oversight at the time.