There are list of source and destinations directories defined in . I need a single task/target to perform the robocopy as per the defined item group properties.
<ItemGroup>
<ItemToCopy Include="$(RootPath)\Audi">
<WhereToCopy>$(FinalFolder)\Audi</WhereToCopy>
<WhatToCopy>*.svc</WhatToCopy>
</ItemToCopy>
<ItemToCopy Include="$(RootPath)\Custom">
<WhereToCopy>$(FinalFolder)\Custom</WhereToCopy>
<WhatToCopy>*.svc</WhatToCopy>
</ItemToCopy>
<ItemToCopy Include="$(RootPath)\Audi\bin">
<WhereToCopy>$(FinalFolder)\Audi\bin</WhereToCopy>
<WhatToCopy>*.*</WhatToCopy>
</ItemToCopy>
<ItemToCopy Include="$(RootPath)\Custom\bin">
<WhereToCopy>$(FinalFolder)\Custom\bin</WhereToCopy>
<WhatToCopy>*.*</WhatToCopy>
</ItemToCopy>
I have tried following code, expecting to perform copy operation for each Items in the deployment folder.
<Target Name="CopyAll">
<RoboCopy
Source="@(ItemToCopy)"
Destination="%(ItemToCopy.WhereToCopy)" Files="ItemtoCopy.Whattocopy"/>
</Target>
In addition, If we see the items 1 & 2 (also 3 & 4), they are same in the sense of copying similar kinds of files from their %ItemName to same path with subdirectory %ItemName. It could be great if we could also avoid that extra code smell. Hoping something like below to work:
<ItemToCopy Include="$(RootPath)\@PublishProjects">
<WhereToCopy>$(FinalFolder)\@PublishProjects</WhereToCopy>
<WhatToCopy>*.svc</WhatToCopy>
</ItemToCopy>
where,
<ItemGroup>
<PublishProjects Include="Audi" />
<PublishProjects Include="Custom" />
</ItemGroup>