title: Web Deployment Project - Copy Files After Build
body: <p>Currently I have set up a Web Deployment Project which compiles code into the <code>.\Release</code> folder. After the build I want to copy the files over to another machine (because whichever directory you build to is deleted then recreated).</p>
  
  <p>The ItemGroup for defining which files to copy is set up as follows:</p>
  
  <pre><code>&lt;ItemGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'"&gt;
      &lt;ReleaseFiles Include=".\Release\**\*" /&gt;
      &lt;OverrideFiles Include="..\website\App_Code\override\site.com\**\*" /&gt;
  &lt;/ItemGroup&gt;
  </code></pre>
  
  <p>'website' is code that is used for multiple sites, so there are several web deployment projects set up within the solution.</p>
  
  <p>Then, I have the AfterBuild target to copy the files:</p>
  
  <pre><code>&lt;Target Name="AfterBuild" Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "&gt;
      &lt;Copy SourceFiles="@(ReleaseFiles)" ContinueOnError="true" SkipUnchangedFiles="true" DestinationFiles="@(ReleaseFiles-&gt;'\\server\web\site.com\%(RecursiveDir)%(Filename)%(Extension)')" /&gt;
      &lt;Copy SourceFiles="@(OverrideFiles)" DestinationFiles="@(OverrideFiles-&gt;'\\server\web\site.com\%(RecursiveDir)%(Filename)%(Extension)')" /&gt;
  &lt;/Target&gt;
  </code></pre>
  
  <p>However, the ReleaseFiles aren't copied, what can be the cause of that? I have had the error <code>.\TempBuildDir\folder\subfolder - The process cannot access the file because it is being used by another process.</code> where <code>folder\subfolder</code> can be different each time, but even when that message doesn't appear the files still aren't copied.</p>
  
  <p>Problem is, it has worked before.</p>