Search code examples
visual-studio-2008w3wp

Can VS 2008 kill w3wp before building a project?


Is there a way that I can make VS 2008 always kill the w3wp process before building a project? I feel like it used to do this on my machine, but now I always have to kill it manually before kicking off a build or else it will fail to deploy the new binaries to my localhost.

EDIT:

If I don't manually kill the process before kicking off a build in VS 2008, I get this error message:

Error 1: Unable to copy file "UPDATED_DLL_I_JUST_BUILT" to "DLL_CURRENTLY_ON_SERVER". The process cannot access the file "DLL_CURRENTLY_ON_SERVER" because it is being used by another process.


Solution

  • As others have said, add a prebuild event. Here is a command:

    taskkill /F /IM w3wp.exe
    

    (As pointed out in the comments, this will not work on Windows XP Home)