title: MSBuild error MSB3021: Unable to copy file. Could not find file 'obj\Release\myWebProject1.dll'
body: <p>When using TeamCity to compile my MSBuild XML task script, it fails with this:</p>
  
  <pre><code>[10:43:03]: myWebProject1\ myWebProject 1 .csproj (3s)
  [10:43:07]: [ myWebProject1\ myWebProject1 .csproj] _CopyWebApplicationLegacy
  [10:43:07]: [_CopyWebApplicationLegacy] Copy
  [10:43:07]: [Copy] C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets(131, 5): error MSB3021: Unable to copy file "obj\Release\myWebProject1.dll" to "C:\MSBUILDRELEASE\myWebProject1\\bin\myWebProject1.dll". Could not find file 'obj\Release\myWebProject1.dll'.
  </code></pre>
  
  <p>When I run it locally, it works.</p>
  
  <p>When I compare my local output to my build server output, there are files missing on my build server. Like the global.asax file is missing from my build server output directory (but not when I compile this locally). Why is that?</p>
  
  <p>Here is my current MSBuildScript:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Project
    xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
    ToolsVersion="4.0"
    DefaultTargets="Build"&gt;
  
    &lt;PropertyGroup&gt;
      &lt;OutputDir&gt;C:\MSBUILDRELEASE&lt;/OutputDir&gt;
    &lt;/PropertyGroup&gt;
  
    &lt;ItemGroup&gt;
      &lt;ProjectToBuild Include="UtilityApp.sln" &gt;
        &lt;Properties&gt;OutputPath=$(OutputDir);Configuration=MSBuildRelease;Platform=x86&lt;/Properties&gt;
      &lt;/ProjectToBuild&gt;
    &lt;/ItemGroup&gt;
  
    &lt;Target Name="Build"&gt;
      &lt;MSBuild Projects="@(ProjectToBuild)"/&gt;
              &lt;CallTarget Targets="Publish WebProject1" /&gt;
              &lt;CallTarget Targets="Publish WebProject2" /&gt;  
    &lt;/Target&gt;
  
  &lt;Target Name="Publish WebProject1"&gt;
   &lt;RemoveDir Directories="$(OutputFolder)"
         ContinueOnError="true" /&gt;
   &lt;MSBuild Projects="WebProject1\WebProject1.csproj"
        Targets="ResolveReferences;_CopyWebApplication"
        Properties="WebProjectOutputDir=$(OutputDir)\WebProject1\;
        OutDir=$(OutputDir)\WebProject1\;Configuration=Release;Platform=AnyCPU" /&gt;
  &lt;/Target&gt;
  
  &lt;Target Name="Publish WebProject2"&gt;
   &lt;RemoveDir Directories="$(OutputFolder)"
         ContinueOnError="true" /&gt;
   &lt;MSBuild Projects="WebProject2\WebProject2.csproj"
        Targets="ResolveReferences;_CopyWebApplication"
        Properties="WebProjectOutputDir=$(OutputDir)\WebProject2\;
        OutDir=$(OutputDir)\WebProject2\;Configuration=Release;Platform=AnyCPU" /&gt;
  &lt;/Target&gt;
  
  &lt;/Project&gt;
  </code></pre>
  
  <p>I can run this script locally and it seems to work fine (no errors generated). When I run it on my build server, it fails with MSBuild error MSB3021.</p>
  
  <p>Now when I compare my local build output files to my server build output files, the server output does not have as many files. For instance, the global.ASAX file is missing in the output on my buildserver. Why would it work local for me, but not on my TeamCity build server? What's the difference and how can I fix it?</p>
  
  <p>I noticed the TeamCity build agent error message has a funny directory path:
  "C:\MSBUILDRELEASE\myWebProject1\bin\myWebProject1.dll"</p>
  
  <p>^ There are two slashes before the bin folder. I do not specify that anywhere. What gives? I have a feeling I am not building my Web Projects correctly (maybe use a different task approach?). It seems to work locally but not on my build server.</p>
  
  <p>Am I building my web projects correctly? These are simply web projects for Web Service (ASMX) deployment. Help?</p>