As part of my build process in MSBuild 4.0, I end up with the following directory structure:
\OutDir
\ProjectA
\File1.dll
\File2.dll
\File3.exe
\ProjectB
\Subfolder1
File4.html
\File5.dll
\File6.dll
\File7.exe
\ProjectC
\File8.dll
\File9.exe
I want to be able to create one zip file per subfolder of \OutDir
. If I do the following:
<ItemGroup>
<ZipSource Include="\OutDir\**.*" />
</ItemGroup>
<MSBuild.Community.Tasks.Zip
Files="@(ZipSource)"
ZipFileName="OutDir\%(ZipSource.RecursiveDir)ZippedOutput.zip"
WorkingDirectory="OutDir" />
then each subfolder is recursively zipped up, which works fine for ProjectA and ProjectC, but ProjectB ends up with two zip files, one of its root level and one of its subfolder.
My other requirement is that the number of projects is not known by the build file, so I can't just create an ItemGroup and enumerate the projects that I want zipped up.
This task would be easy in NAnt through its foreach task, but how can I achieve this in MSBuild, preferably without resorting to custom tasks?