Scott Hanselman

"Could Not Copy Temporary Files to the Output Directory" and big VS.NET projects

June 07, 2004 Comment on this post [4] Posted in ASP.NET | Nant
Sponsored By

A fellow emailed me about the troubles he was having with his VS.NET solution.  He's trying to build into a shared binaries folder and is using direct Assembly references (rather than project references.) 

In fact, it appears that Intellisense is locking his assemblies just long enough to get one of the dreaded:

  • Could not copy temporary files to the output directory.
  • The file 'assembly name' cannot be copied to the run directory. The process cannot access the file because it is being used by another process.
  • error CS0016: Could not write to output file 'fully qualified path of an assembly' -- 'The process cannot access the file because it is being used by another process. '
  • Cannot delete the project output: is the file read-only? A failure occurred while attempting to start the application.

And that sucks.  Basically if you turn Copy Local to False and compile to one folder, you're screwed.

The moral?  We use NAnt for all builds.  It's fairly simple, repeatable, and IJW.  Otherwise, if your goal is to get all files to a shared bin, use a Post Build Event.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
June 07, 2004 22:00
Hey Scott,

I don't know if you guys are doing it, but my team uses a pretty handy little trick to kick off nant from within VS.NET: Tools -> External Tools. We just kick nant.exe with the right arguments and redirect the output to the VS Output window. You can even click on the compilation errors and jump to the appropriate part of the source code. Plus, you can do other fun things in the build file, like automatically kick off nunit, but I won't go into that. :)

What technique do you folks use to integrate NAnt into VS?
June 08, 2004 6:23
I had this same problem (randomly). I finally solved it. I turned off the Indexing Service and never had the issue again.

Hope this helps someone. I'm not totally sure it applies here, but it sounds like the same issue I've had before.

Anyway, NAnt does rock! We use it for our build process, but not for debugging applications. We haven't gotten to VS integration with it (yet!).

June 08, 2004 18:24
I remember a discussion on this during the 2001 PDC. The presenter said that Intellisense memory maps the assembly if it's over a certain size and the problem described above will happen. They said they hoped to fix it in a future version, that was pre-VS.NET 2002. Anybody tried it in VS.NET 2005 yet?
June 11, 2004 20:40
Interesting, I clicked on the "Comments" link for the Linux Torvalds post and I'm taken to the comment section for the ""Could Not Copy Temporary Files to the Output Directory" and big VS.NET projects" post.??!

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.