Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Project Collection Build Services locking my files

I'm sorry if I'm misunderstanding the problem but I'm relatively new to TFS and am having some locking issues. When I'm trying to save/change my files, I get an error that says:

Cannot lock items, the item is checked out by Project Collection Build Service.

What are some of the reasons this may be happening? This happened shortly after I queued a new build.

Thank you.

like image 626
TomPuts Avatar asked Aug 11 '16 17:08

TomPuts


People also ask

How to remove lock from file in TFS?

File -> Source Control -> Advanced -> Workspaces... In the dialog that came up, I checked "Show remote workspaces" and the locked workspace came up in the window. I then selected it and clicked "Remove". Save this answer.

How do you unlock a file in Visual Studio?

In Source Control Explorer, open the shortcut menu for the folder or file from which you want to remove a lock, and then choose Unlock.

How many types of locks are provided by TFVC?

Team Foundation provides two types of locks: checkin and checkout. A check-in lock is less restrictive than a check-out lock. When you apply a check-in lock, users can continue to make local changes to the item in other workspaces.


2 Answers

Seems you are using the gated check in build with TFS.

If you are using XAML build, when the build completes and shows success, you need to wait about few minutes or longer if changeset is bigger for TFS to check in. So during that, the edited files will still show checked-out even build has finished. Just be patient and wait. When TFS finish checking in pending changes, everything should be OK.

If you are using vNext build, the Gate Check-in build feature only available with TFS 2015 Update 2 and later. Sometimes you may meet the situation. Even though the build has finished in TFS ,but Visual Studio isn't synchronized automatically. So the files always show like checked out. As a workaround, you can close Visual Studio and came back a bit later. The files should no longer showed checked out by the build service account.


Update

First check in all your pending changes. Then try to clear VS and TFS cache on your client and build agent machine.

like image 154
PatrickLu-MSFT Avatar answered Oct 25 '22 00:10

PatrickLu-MSFT


I had the same problem. For some reason the "Project Collection Build Service" was locking a file after a Gated Check-in. We runned the following script into the Developer Command Prompt for VS:

tf undo /workspace:<workspace_name>;"Project Collection Build Service" <REPO_PATH_WITH_LOCK>

[UPDATE]: A definitive solution would be something like proposed here: How to prevent TFS 2013 from locking binary files?

like image 2
Adailson De Castro Avatar answered Oct 25 '22 01:10

Adailson De Castro