Daniel Doubrovkine bio photo

Daniel Doubrovkine

aka dB., @awscloud, former CTO @artsy, +@vestris, NYC

Email Twitter LinkedIn Github Strava
Creative Commons License

I never remember how to do this, so here’s a refresher. In MSBuild you can easily define a list with properties and iterate over it.

<Project DefaultTargets="all" xmlns="https://schemas.microsoft.com/developer/msbuild/2003" >
  <ItemGroup>
    <Squirrel Include="Bob">
      <Color>green</Color>
      <Teeth>white</Teeth>
    </Squirrel>
    <Squirrel Include="Marc">
      <Color>orange</Color>
      <Teeth>yellow</Teeth>
    </Squirrel>
  </ItemGroup>
  <Target Name="ShowSquirrels" Inputs="@Squirrel" Outputs="%(Squirrel.Identity)">
    <Message Text="%(Squirrel.Identity) is an %(Squirrel.Color) squirrel with %(Squirrel.Teeth) teeth" />
  </Target>
</Project>

Run the sample above with msbuild test.proj /t:ShowSquirrels.