Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.
If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!
Transfer-Files doesn't release file after copying it?
-
As part of my deployment plan, I copy a single file from one folder to another on the same box (it happens to be the BuildMaster server). It works fine. Subsequent executions, however, fail because BuildMaster can't get a handle on the file.
Cannot copy C:\folder1\foo.msi: The process cannot access the file 'C:\folder1\foo.msi' because it is being used by another process.
This is how I copy it in my plan:
Transfer-Files ( Include: foo.msi, FromDirectory: C:\folder1, FromServer: localhost, ToDirectory: C:\folder2, ToServer: localhost, DeleteTarget: true, Verbose: true );
The only way to get it to work on subsequent executions is to restart the BuildMaster service (which releases the handle on the file).
Product: BuildMaster
Version: 5.6.11
-
Sorry, but my original error message is actually:
Cannot copy C:\folder1\foo.msi: The process cannot access the file 'C:\folder2\foo.msi' because it is being used by another process.
-
BuildMaster does not lock files in this manner, especially when reading a file. But this is very common for other tools that monitor the file system to do this:
- Anti-virus, anti-malware
- Auditing
- File indexing
Restarting the service is basically just giving these other tools time to release whatever locks they have acquired. The best solution is to disable those tools for your own files, but when it's not possible, you can easily use a retry block like this:
with retry=3 { try { transfer-files; } catch { sleep 3; } }
-
Thanks, I believe this was caused by the anti-virus program. Once I excluded the folder from the scan, the problem went away.