MSBuild error MSB3021: Unable to copy file. Could not find file 'obj\Release\myWebProject1.dll'

Hello,

I am having a problem using TeamCity with MSBuild. I have a .NET solution with 30+ projects. Only two of the projects are "web" projects.

When I use the Visual Studio command line prompt to run my MSBuild script (both locally and even on my build server itself), the output is good, fine and dandy. All my build files are there. Everyone is happy. No errors.

When I use TeamCity to compile the exact same script (triggered by VCS SVN checkins), it gives me an error, like this:


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'.


Why does it work from the command line and not through TeamCity? This is a major show stopper for my dev team. We are excited to get automated builds up and running, but this bothers us.
Why would TeamCity compile this differently? What gives?

8 comments
Comment actions Permalink

Here is my build script:

 
<?xml version="1.0" encoding="utf-8"?>
<Project
  xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
  ToolsVersion="4.0"
  DefaultTargets="Build">

  <PropertyGroup>
    <OutputDir>C:\MSBUILDRELEASE</OutputDir>
  </PropertyGroup>

  <ItemGroup>
    <ProjectToBuild Include="UtilityApp.sln" >
      <Properties>OutputPath=$(OutputDir);Configuration=MSBuildRelease;Platform=x86</Properties>
    </ProjectToBuild>
  </ItemGroup>

  <Target Name="Build">
    <MSBuild Projects="@(ProjectToBuild)"/>
               <CallTarget Targets="Publish WebProject1" />
               <CallTarget Targets="Publish WebProject2" />  
  </Target>

<Target Name="Publish WebProject1">
<RemoveDir Directories="$(OutputFolder)"
       ContinueOnError="true" />
<MSBuild Projects="WebProject1\WebProject1.csproj"
      Targets="ResolveReferences;_CopyWebApplication"
      Properties="WebProjectOutputDir=$(OutputDir)\WebProject1\;
      OutDir=$(OutputDir)\WebProject1\;Configuration=Release;Platform=AnyCPU" />
</Target>

<Target Name="Publish WebProject2">
<RemoveDir Directories="$(OutputFolder)"
       ContinueOnError="true" />
<MSBuild Projects="WebProject2\WebProject2.csproj"
      Targets="ResolveReferences;_CopyWebApplication"
      Properties="WebProjectOutputDir=$(OutputDir)\WebProject2\;

      OutDir=$(OutputDir)\WebProject2\;Configuration=Release;Platform=AnyCPU" />
</Target>

</Project>
0
Comment actions Permalink

No ideas?

I think I am going try Cruise Control instead of Team City.

0
Comment actions Permalink

Please check if you call necessary build tasks when building .csproj or .sln files. The could could succseed locally, because those files were in the expected location. Will the script run on clean machine?

0
Comment actions Permalink

Im not sure what you mean "clean" machine.

The script runs fine from the command line, when I invoke it through DOS. It works perfect.

When I use TeamCity, (and use the same exact build script)....I get the error.

0
Comment actions Permalink

The 'clean machine' I meant the machine that never had your build script running. There could be a stale files under 'Obj' directory that make the build to pass.

Please check what user account is used to run build agent windows service. There are some limitations on this: http://confluence.jetbrains.net/display/TCD6/Known+Issues#KnownIssues-AgentrunningasWindowsServiceLimitations
Check you use local administrative accout with enough right to run the build.

Check you specified the same targets, properties in TeamCity as you use them locally to run the build.

Have you specified any custom commandline arguments?

0
Comment actions Permalink

Yeah sorry, this is not a "security" issue. I notice most of the people having this trouble do have security problems, but this is not the case for me at all.

teamCity can build successfully if I remove my web projects from the build configuration. Its only when it tries to build the web projects in my .SLN file.

I am able to build the script with MSBuild in under 12 seconds. TeamCity takes 1:30 to tell me it fails.

I have successfully installed CruiseControl.NET and it builds everything just fine.

0
Comment actions Permalink

Also crossposted as TW-15644.

0
Comment actions Permalink

To anyone here from Google or any other indexer check out that link to the issue listed above, I added some of my own findings to it which you may find helpful.

0

Please sign in to leave a comment.