Scott Hanselman

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

June 7, '04 Comments [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
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb
Monday, 07 June 2004 18:00:06 UTC
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?
Tuesday, 08 June 2004 02:23:06 UTC
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!).

Joel
Tuesday, 08 June 2004 14:24:59 UTC
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?
Greg
Friday, 11 June 2004 16:40:42 UTC
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.