how to do looping in msbuild to increment variable value?

1.1k views Asked by At

i want to increment value N where n E {1...5}.how can increment value of N using msbuild.because i want to do same operation 5 times.

so can i do looping in ms build ?please help me to solve this problem

1

There are 1 answers

1
Ludwo On

You can do it this way:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
    <ItemGroup>
        <!-- Define value N where n E {1...5} -->
        <VariableN Include="1"/>
        <VariableN Include="2"/>
        <VariableN Include="3"/>
        <VariableN Include="4"/>
        <VariableN Include="5"/>
    </ItemGroup>

    <!-- Testing target -->
    <Target Name="Test">
        <!-- Testing task. Task will be executed 5times. -->
        <Message Text="VariableN = %(VariableN.Identity)"/>
    </Target>
</Project>