Windows – Avoiding “file locked for reading” problems with Windows file shares

file-sharingnetwork-sharewindows

Our build environment pumps out the latest build onto a Windows file share in a predefined location. We get file lock problems when remote users open and maintain folders and files on that read-only file share, and this causes our builds to break.
Is there any technology that can solve this for us?

I've thought about

  • DFS-R
  • BranchCache
  • Enabling only WebDav and disabling SMB (can you?)

but none of those candidate solutions seem like a great fit so far.

To clarify, assume the path to the "latest build" is \server\share\path\Latest and only the build server has write access. Someone has opened a command prompt or an msi file somewhere in the "Latest" folder. Now the build server is done and needs to purge all content from the folder before copying in all the newly built pieces. No can do.

If an SMB share had had symbolic link support or some idea of transactions like NTFS or being able to rename "open" directories like HFS – but nope.

And putting all binaries in Sharepoint Document folders as has been suggested elsewhere seems like a crappy idea as well because of the data volume. I'd rather go for a WebDAV-only share that mounts like a file system but behaves like a web site.

Best Answer

Do you mean they're actually editing these files, or this is some kind of situation where no one is actually using the files but there's a file lock on them?

If they're actually using those files (or have the file open in an editor while they're out having a donut) then you probably don't want those files to be opened in any way other than with an application that opens them with read-only copies or you'll have potential corruption. You said the file share is read-only though. So what are they doing that wouldn't allow multiple opens on the file as read-only? You don't mention what your build process is either, so maybe this is specific to that workflow?

Your best solution may be to try isolating your build environment from your development environments. Have a development process that checks out from a repo all your sources and builds them on a dedicated server and dedicated share, away from anything touched by your developers. That way you don't need to worry about devs altering something or breaking your build process, and the build process won't need to worry about anything being changed as it's working.