title: MSBuild and creating ZIP files
body: <p>Here is my build script:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
    &lt;Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/&gt;
    &lt;PropertyGroup&gt;
      &lt;!-- Path where the solution file is located (.sln) --&gt;
      &lt;ProjectPath&gt;W:\Demo&lt;/ProjectPath&gt;
      &lt;!-- Location of compiled files --&gt;
      &lt;DebugPath&gt;W:\Demo\bin\Debug&lt;/DebugPath&gt;
      &lt;ReleasePath&gt;W:\Demo\bin\Release&lt;/ReleasePath&gt;
      &lt;!-- Name of the solution to be compiled without the .sln extension --&gt;         &lt;ProjectSolutionName&gt;DemoTool&lt;/ProjectSolutionName&gt;
  
      &lt;!-- Path where the nightly zip file will be copyd --&gt;
      &lt;NightlyBuildPath&gt;W:\Nightly_Builds\Demo&lt;/NightlyBuildPath&gt;
      &lt;!-- Name of the nighly zip file (YYYYMMDD_NightlyZipName.zip, date added automatically) --&gt;
      &lt;NightlyZipName&gt;Demo&lt;/NightlyZipName&gt;
    &lt;/PropertyGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;!-- All files and folders from ./bin/Debug or ./bin/Release what will be added to the nightly zip --&gt;
      &lt;DebugApplicationFiles Include="$(DebugPath)\**\*.*" Exclude="$(DebugPath)\*vshost.exe*" /&gt;
      &lt;ReleaseApplicationFiles Include="$(ReleasePath)\**\*.*" Exclude="$(ReleasePath)\*vshost.exe*" /&gt;
    &lt;/ItemGroup&gt;
  
    &lt;Target Name="DebugBuild"&gt;
      &lt;Message Text="Building $(ProjectSolutionName) Debug Build" /&gt;
      &lt;MSBuild Projects="$(ProjectPath)\$(ProjectSolutionName).sln" Targets="Clean" Properties="Configuration=Debug"/&gt;
      &lt;MSBuild Projects="$(ProjectPath)\$(ProjectSolutionName).sln" Targets="Build" Properties="Configuration=Debug"/&gt;
      &lt;Message Text="$(ProjectSolutionName) Debug Build Complete!" /&gt;
      &lt;CallTarget Targets="CreateNightlyZip" /&gt;
    &lt;/Target&gt;
  
    &lt;Target Name="CreateNightlyZip"&gt;
      &lt;PropertyGroup&gt;
        &lt;StringDate&gt;$([System.DateTime]::Now.ToString('yyyyMMdd'))&lt;/StringDate&gt;
      &lt;/PropertyGroup&gt;
      &lt;MakeDir Directories="$(NightlyBuildPath)"/&gt;
      &lt;Zip Files="@(DebugApplicationFiles)"
            WorkingDirectory="$(DebugPath)"
            ZipFileName="$(NightlyBuildPath)\$(StringDate)_$(NightlyZipName).zip"
            ZipLevel="9" /&gt;
    &lt;/Target&gt;
  &lt;/Project&gt;
  </code></pre>
  
  <p>My script works perfectly, only there is one strange problem. When i build a project first time and there is no <code>\bin\Debug</code> folder and its created during the build, but the ZIP file still comes empty. Running the build script second time when the <code>\bin\Debug</code> folder is now in place with builded files then the file are added to the ZIP.</p>
  
  <p>What could be the problem that running script first time the ZIP file is empty?</p>