6

ItemGroup이 적합한 유형인지 알 수 없습니다. 나는 선택에 따라 참이거나 거짓이 될 4 가지 부울을 얻을 것이다.MSBuild ItemGroup with condition

나는이 "문자열"을 true 또는 false에 따라 ItemGroup으로 채우고 싶습니다. 그게 가능한가, 아니면 내가 사용해야 할 것인가?

Anders = true 
Peter = false 
Michael = false 
Gustaf = true 

ItemGroup 다음 앤더스와 구스타프이 있어야합니다.

그럴 수 있습니까? 아니면 어떻게 해결해야합니까?

+0

어떤이 "문자열"입니다 : 그들은 속성이어야합니다

<ItemGroup> <Names Include="Anders"> <Value>True</Value> </Names> <Names Include="Peter"> <Value>False</Value> </Names> <Names Include="Michael"> <Value>False</Value> </Names> <Names Include="Gustaf"> <Value>True</Value> </Names> </ItemGroup> <Target Name="GetNames"> <ItemGroup> <AllNames Include="%(Names.Identity)" Condition="%(Names.Value)==true"/> </ItemGroup> <Message Text="@(AllNames)"/> <!--AllNames contains Anders and Gustaf--> </Target> 

그러나, 나는과 같이 수동으로 그들 모두를 열거하는 것보다 다른 방법이라고 생각하지 않습니다? 텍스트 파일에 있습니까? 그들은 msbuild 속성입니까? 또한 철자를 확인하십시오. itItem 그룹이 아닌'ItemGroup'입니다. – stijn

+0

msbuild properites – user1540911

답변

9

아이템이 많으므로 처음부터 ItemGroup에 저장하는 편이 좋을 것입니다. 결국 그것이 의미하는 바이며 변형 등을 허용하기 때문입니다. 예를 들어 다음과 같이하면됩니다.

<PropertyGroup> 
    <Anders>True</Anders> 
    <Peter>False</Peter> 
    <Michael>False</Michael> 
    <Gustaf>True</Gustaf> 
</PropertyGroup> 

<Target Name="GetNames"> 

    <ItemGroup> 
    <AllNames Include="Anders" Condition="$(Anders)==true"/> 
    <AllNames Include="Peter" Condition="$(Peter)==true"/> 
    <AllNames Include="Michael" Condition="$(Michael)==true"/> 
    <AllNames Include="Gustaf" Condition="$(Gustaf)==true"/> 
    </ItemGroup> 

    <Message Text="@(AllNames)"/> 
</Target>