MSBuild tasks can accept ITaskItem
, primitives, string or an array of any of those for parameters. You just declare the type in your task and then the values will be converted before passed to the task. If the value cannot convert to the type then an exception will be raised and the build will be stopped.
For example if you have a task which accepts an int[]
named Values then you could do.
<Target Name="MyTarget">
<MyTask Values="1,45,657" />
<!-- or you can do -->
<ItemGroup>
<SomeValues Include="7,54,568,432,79" />
<MyTask Values="@(Values) />
</ItemGroup>
</Target>
Both approaches are essentially the same. The other answers stating that all parameters are strings or that you have to use ITaskItem
are incorrect.
You said you have two books on MSBuild, then I presume one is my Inside the Microsoft Build Engine book, you should read the chapter on Custom Tasks so that you get a full grasp on these topics. There is a section explaining parameter types specifically.