Title: msbuild itemgroup items
Tags: batch-file;msbuild;msbuild-itemgroup
Question: I have msbuild file which is executing batch file.

Msbuild file:
    

```<PropertyGroup&gt;
    <ItemAString&gt;Green;Red;Blue</ItemAString&gt;
    <ItemBString&gt;Uno;Due;Tre</ItemBString&gt;
    <ItemCString&gt;Song;Movie;Picture</ItemCString&gt;
</PropertyGroup&gt;

<ItemGroup&gt;
    <ItemsA Include="$(ItemAString.Split(';'))" /&gt;
    <ItemsB Include="$(ItemBString.Split(';'))" /&gt;
    <ItemsC Include="$(ItemCString.Split(';'))" /&gt;
</ItemGroup&gt;

<Target Name = "CallBatch"&gt;                     
    <!-- THIS DOES NOT WORK  --&gt;
    <Exec Command="mybatch.bat %(ItemsA.Identity) %(ItemsB.Identity) %(ItemsC.Identity)" /&gt;             
</Target&gt;       
```



Batch file is very simple:

```echo Params = [%1] - [%2] - [%3]
```

I want to get next output:

```Params = Green - Uno - Song
Params = Red - Due - Movie
Params = Blue - Movie - Picture
```

How to achieve this?

Comment: Search around for 'cross-product', answer should be on here somewhere. Example: http://stackoverflow.com/questions/3893467/msbuild-batching-on-three-independent-variables/3893905#3893905 or http://stackoverflow.com/questions/37186867/msbuild-merge-item-groups/37210038#37210038 or ...

Comment: Not sure if thats correct, but you are first accessing variables with `$` and then with `%`. I am not into msbuild but that jumps to my eyes.

Here is the accepted answer: I found solution:

```<Project DefaultTarget="DoTheMagic" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="12.0"&gt;
<PropertyGroup Condition=" '$(TFP)'=='' "&gt;
    <TFP&gt;$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll</TFP&gt;
    <TFP Condition=" !Exists('$(TFP)')"&gt;$(MSBuildFrameworkToolsPath)\Microsoft.Build.Tasks.v4.0.dll</TFP&gt;
    <TFP Condition=" !Exists('$(TFP)')"&gt;$(windir)\Microsoft.NET\Framework\v4.0.30319\Microsoft.Build.Tasks.v4.0.dll</TFP&gt;
</PropertyGroup&gt;

<UsingTask
    TaskName="Bukake"
    TaskFactory="CodeTaskFactory"       
    AssemblyFile="$(TFP)" &gt;
    <ParameterGroup&gt;
        <ItemsA Required="True" ParameterType="System.String"/&gt;
        <ItemsB Required="True" ParameterType="System.String"/&gt;
        <ItemsC Required="True" ParameterType="System.String"/&gt;
        <Result ParameterType="Microsoft.Build.Framework.ITaskItem[]" Output="True"/&gt;
    </ParameterGroup&gt;
    <Task&gt;                      
        <Code Type="Fragment" Language="cs"&gt;
            <![CDATA[
        string[] itemsA = ItemsA.Split(new char[] {';'}, StringSplitOptions.RemoveEmptyEntries);
        string[] itemsB = ItemsB.Split(new char[] {';'}, StringSplitOptions.RemoveEmptyEntries);
        string[] itemsC = ItemsC.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

        List<TaskItem&gt; items = new List<TaskItem&gt;();
        for (int index = 0; index < itemsA.Length; index++)
        {                            
            TaskItem item = new TaskItem();
            item.ItemSpec = "item";
            item.SetMetadata("itemA", itemsA[index]);
            item.SetMetadata("itemB", itemsB[index]);
            item.SetMetadata("itemC", itemsC[index]);
            items.Add(item);
        }
        Result = items.ToArray();                         
        ]]&gt;
        </Code&gt;
    </Task&gt;
</UsingTask&gt;

<PropertyGroup&gt;
    <ItemAString&gt;Green;Red;Blue</ItemAString&gt;
    <ItemBString&gt;Uno;Due;Tre</ItemBString&gt;
    <ItemCString&gt;Song;Movie;Picture</ItemCString&gt;       
</PropertyGroup&gt;

<Target Name = "CallBatch"&gt;    
    <Message Text="$(TFS)" /&gt;   
    <Bukake ItemsA="$(ItemAString)" 
            ItemsB="$(ItemBString)"
            ItemsC="$(ItemCString)"&gt;
        <Output TaskParameter="Result" ItemName="Dundonja" /&gt;
    </Bukake&gt;

    <ItemGroup&gt;                 
        <PreparedItems Include="@(Dundonja)"/&gt;              
    </ItemGroup&gt;
    <!-- <Message Text="Dundonja: %(Dundonja.Identity) %(Dundonja.itemA) %(Dundonja.itemB) %(Dundonja.itemC)"/&gt;          --&gt;
    <Exec Command="mybatch.bat Dundonja %(Dundonja.Identity) %(Dundonja.itemA) %(Dundonja.itemB) %(Dundonja.itemC)"/&gt;
</Target&gt;       
```





{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2016:00:12/15/16', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<batch-file><msbuild><msbuild-itemgroup>', 'Title': 'msbuild itemgroup items', 'ViewCount': 496, 'id': 41169478, 'user_AboutMe': None, 'user_AccountId': 9859484.0, 'user_DisplayName': 'Klik Kliković', 'user_Reputation': 324.0, 'user_Views': 36.0, 'user_id': 7302971.0}}