title: How to zip multiple project folders in a solution using MSBuild tasks
body: <p>I want my project's build task to dynamically zip contents of each sub folder under the directory "Projects" in my solution to a separate zip file.</p>
  
  <p>My project directory looks like follows</p>
  
  <pre><code>sources\
  common\
  Projects\
   Project1\
     file1.xml
     file2.xml
    Project2\
     Folder1\
       file1.xml
     Folder2\
        file2.xml
    Project3\
        file1.xml
  </code></pre>
  
  <p>This is the build task file in .proj file</p>
  
  <pre><code> &lt;Target Name="Zip"&gt;
      &lt;CreateItem Include="Projects\**\*.*"&gt;
        &lt;Output ItemName="ZipFiles" TaskParameter="Include" /&gt;
      &lt;/CreateItem&gt;
      &lt;Zip ZipFileName="$(ReleaseDir)\zip\Projects.zip" WorkingDirectory="$(ReleaseDir)" Files="@(ZipFiles)" /&gt;
    &lt;/Target&gt;
    &lt;Target Name="AfterBuild"&gt;
      &lt;CallTarget Targets="Zip" /&gt;
    &lt;/Target&gt;
  </code></pre>
  
  <p>This is zipping up the entire Projects folder into a single zip file but not how I want ie, Project1.zip, Project2.zip, Project3.zip etc.</p>
  
  <p>How can I change this to produce one zip file for each folder under "Projects"?</p>