Tuesday 30 November 2010

MSBuild calling same target multiple times

If you are doing similar tasks within a build, you can set-up a target and call it multiple times, like copying files between directories. You can pass in parameters like variables, to keep the methods as generic as possible.

An example:
<MsBuild Projects="$(MSBuildProjectFile)" Targets="MethodName" Properties="Param1=Value" />

<Target Name="MethodName">
<ItemGroup>
<Path Include="Source\$(Value)"/>
</ItemGroup>
...
</Target>

No comments: