How can I test if an item list contains a particular value?


Unfortunately, we don't have support for testing if an item list contains a particular item. However you can work around it using something like the following:

Imagine you have an item list like the following:

		 [<ItemGroup>]
		     [<SomeValue] Include="One"/>
		     [<SomeValue] Include="Two"/>
		     [<SomeValue] Include="Three"/>
		 [</ItemGroup>]
	

Then, use a batching <CreateProperty /> to "find" the value:

		 [<CreateProperty] Value="false">
	
<Output TaskParameter="Value"
		                 PropertyName="DoesContainMyValue"/>
		 [</CreateProperty>]
		 [<CreateProperty] Value="true"
		                 Condition="'%(SomeValue.Identity)' == '$(MyValue)'">
	
<Output TaskParameter="Value"
		                 PropertyName="DoesContainMyValue"/>
		 [</CreateProperty>]
	

Then you can test the single value:

		   Condition="'$(DoesContainMyValue)' == 'true'" >
	
Microsoft Communities