Related: How to force delete a file?
I have a NAnt script that does a full build and deployment to our Dev environment. Deploying the C#.Net Win exe and its used DLLs involves moving them to a network location, where our testers and other developers run them.
<copy todir="${dest.dir}" overwrite="true" failonerror="false" >
<fileset basedir="${source.dir}" >
<include name="**/*" />
</fileset>
</copy>
Right now, the script calls the Copy task, with Overwrite="true", but this fails if anyone is running the application, reporting
Cannot copy 'source.dll' to 'dest.dll'. Access to the path 'dest.dll' is denied.
"dest.dll" is one of the main EXE's dependencies, copied along with it. Right now, I have one of two recourses: I either figure out who has it open and ask them to quit, or I send an email to our systems engineers and they do some voodoo to delete the locked file. Is there anyway I can incorporate some of my own voodoo into the NAnt script, so the file copy always succeeds?