TFS Conflict Type: Writable File - A writable file by same name exists locally - visual-studio-2010

I'm trying to get latest of my project. When I do, TFS shows me that I have conflicts on every single file in that project. Every file has the same conflict: Conflict Type: Writable File - A writable file by same name exists locally.
The resolution it gives me is "Overwrite Local File or Folder" but I have to do this one by one.
Why does TFS thinks that I have conflicts (I haven't changed any files)?

The Visual Studio 2010 conflict resolution dialog supports multi-select.
If you select the first conflict, hold down Shift then select the last conflict, the "Overwrite Local File or Folder" resolution will be applied to all the selected conflicts.
You can also use the command-line tool tf resolve /auto:OverwriteLocal to resolve the conflicts.

Grant's answer is great for how to resolve multiple conflicts.
As for why you have those conflicts, generally speaking, your TFS client has detected that a file exists locally that is not managed by TFS, but you are trying to perform a get operation that would overwrite that file.
If you're following a normal development workflow (and not going and editing files outside of your editor), the most common source of writable conflicts is from shelvesets. If you were to pend an add on a file, then you were to undo that add (either explicitly or because you shelved the change and deselected the preserve pending changes button), the file is not deleted. (This is to prevent data loss - it's not uncommon that you would want to create a file but not have it checked in to source control.)
Now if you (or someone else) were to check in that shelveset (either through creating a build from that shelveset, or from gated check-in, or because your code reviewer checked in your shelveset directly), then when you do a get latest, your TFS client will detect that the file still exists locally and thus, you'll have a writable conflict.
This may not be particularly obvious in the case of gated check-in. How gated check-in actually works is when you try to check in your changes, your check-in is actually converted to a shelveset. The TFS build agent will then try to build your shelveset, and if the build succeeds, it will then check-in that shelveset on your behalf. If the build fails, the shelveset remains and you can unshelve to fix the build errors.
For this reason, it's important to run the build notification application when you're using gated check-in, which will allow you to "reconcile" your changes once they're submitted. Reconciling your check-in will simply do a get of the check-in that was submitted by the build server, but it will avoid conflicts since it understands the context of the changes that are on your local disk. (It will compare the contents on your local disk to the contents on the server.) If you do not choose to reconcile, you will, unfortunately, have writable conflicts on files that were added.
(Note that this scenario will not produce a conflict in the next version of TFS - if there are no content differences, TFS will not produce a conflict.)

You can do it for whole folder, multiple folders or entire project where conflict files exist.
You need to right click on that specific file/folder, go to Advanced, Select "Get Specific Version..."

You must have all Rights (Full control) to a specific local file or folder. Check it out. If it's not true you have to delete all local files, change Rights and then get latest files from server.

Related

How to Resolve TFS Issue when checking files in

I have a project under source control using TFS and Azure DevOps.
It all works normally except for one thing: When I check in a file, I get this error message:
TF10122: The path '$/KnowledgeBuilder/V2/$tf/1/1f8c47a1-8066-42d7-b56c-c9960b0ee7ea.gz' contains a '$' at the beginning of a path component. Remove the '$' and try again.
The check-in does in fact succeed, but I get three of the above error messages each time. I can simply ignore this, but it is starting to get annoying.
It appears the folder in question is a TFS created and controlled folder. I tried deleting the folder, but that remove the Project from Source Control, so I restored them.
Is there a way to resolve this?
This occurs in VS22 on a Blazor Server Project. I have tried opening the Project in VS19, making a change, and then checking it in, and it works fine. So, it must be something specific to VS22.
Someone, sometime, at some point, added that $tf folder to version control. It should not be there, ever, under any circumstances -- that's the folder that TFVC uses to track local workspaces. That's why removing it messes up your workspace.
Make sure any pending changes are committed or shelved first.
Remove that folder from source control. Make sure the change is checked in. You might need to use a server workspace to do this so that the $tf folder isn't relevant.
Use tf get to force a re-sync of your local workspace. tf get /all /overwrite should do the trick. If it doesn't, then just delete and recreate the workspace.
Add $tf to your .tfignore file (although if memory serves, that shouldn't be strictly necessary -- I haven't worked with TFVC in a few years)

Restrict to commit file in checked-out state in TFS

I have two branches say dev and rel. If I am changing file 'A' under dev and without commiting I will mergr to rel, I am getting change status as "[merge]". And If change the file, commit it in dev and then merge to rel status will be "[merge,edit]".
Is there is any option in VS 2013 where it should not allow to merge the file for developers if it is in checked-out state.
Scenario:
One file already committed to the server with change and second file is in checked out mode and not checked-in to the server.
So first file merged separately which got merged and then after changing the second file, added first and second file in single change set with checked out mode of second file. So no conflicts while merging because second file code was in checked out mode..
How to go ahead where - Developer cannot merge if file is in edit mode.. it should allow only when changes are checked in to server.
No this isn't possible. The ability to edit files during merge is required in order to be able to perform conflict resolution.
In TFS, merge specifically means that its this revision contains the merge from a another branch. however,merge only represent the merge operation. So it shows [merge] status for the unchanged file and shows [merge,edit] status for the files that actually changed and shows [merge branch] for the new add item.
It's not possible to restrict users to do the merge files when the files be checked out. This is used to resolve the conflicts.
We do not have this kind of build-in feature for local workspace. If you are using server workspace, you could try to sue Check-out lock for target branch, a check-out lock prevents users who are using server workspaces from checking out and making changes to the locked item in their workspaces. You cannot apply a check-out lock to an item for which any pending changes exist, in any workspace other than your own. More details take a look at this link.

TFS Merge Deadlock

I am attempting to perform a merge in TFS. After completing the Merge Wizard I received conflicts with most of my files. They were all “Existing File” conflicts with the error below
“a non version controlled file or writable file by the same name already exists locally”
I chose to overwrite all local files. When I open the target solution all of the changes I am attempting to merge are not there and I receive build errors. However, when I select “Check-In” - I can see them under Included Changes as [merge, edit] or [merge,branch]. It’s like they’re in some indeterminate state.
I’m not exactly sure how to get pass this. I tried to check-in the changes and I receive an error telling me to “Get Latest.” When I try “Get Latest” – I receive the message “Unable to perform the get operation because the file already exists locally”
Any ideas on how to get past this deadlock?
The target branch which in your local work space compare with the one in source control explorer must be some conflicts.
A simple way to solve it. You can delete your local mapped target branch(copy a backup to a different folder ).Then get latest version of the target branch from source control. Do the merge again, check in the pending changes.

TFS - dll is locked for check-out by user

2 projects under TFS Source Control.
DependancyProject.sln
AppProject.sln
With AppProject referencing DependancyProject.
-
The issue I have is with an Installer project in the AppProject.
It has DependancyProject.dll as a 'reference'(?) where it tries to include it in the GAC.
When I try to build this project, to create an MSI to install the App, I get the error
The item $/Assemblues/DependancyProject/bin/debug/DependancyProject.dll is locked for check-out by USER in workspace HIS-PC-NAME.
(The PC in question is not dead and not used)
The dll is not (as far as I can see) checked into Source Control.
The path it references anyway does not exist when I browse through it (no bin folder).
The DependancyProject is refernced by pretty much every project in Source Control, and i've never had any issues with it.
It builds, all the other projects build.
It's just this one Installer Project which doesn't.
And I can't see why it would need to try and modify it anyway.
All it needs to do (I'm assuming) is make a copy of it.
Any ideas here?
Some files are configured as "non-mergeable" in TFS, which means that they'll be locked when changes are pended on them. The default list includes a variety of binary files, including .dll files. Note that this lock applies to all pending changes - including adds.
It's likely that the other developer in question accidentally pended adds for his bin directory - and any binary files in that directory (ie, most of them) would have been locked as well due to being in that unmergeable list.
You will not be able to pend other changes (including an add in a different workspace) while these items are locked. To break this lock, the other developer can do this by undoing the pending changes, or a server administrator can do it using the Find in Source Control functionality in the Team Foundation Server Power Tools.
That said, I don't know why your build process is trying to pend an add on that file.
I had the same problem, and this guide solved all my problems.
The file was actually locked by me, but in a different work space (old computer).
Had to use the tf undo command to unlock the files.
If you are not going to use that workspace again, you can delete it by going to workspace pull down, selecting workspaces, and enabling the check box "Show remote workspaces". you can then select it and remove it.

TFS 2010 Gated Checkin with Exclusive Checkouts

We are using TFS 2010 with gated checkins. I've got some question about what I think is strange behaviour. Look at the following process:
File A is checked out by me exclusively.
File A is changed
File A is checked in
TFS asks to build changes
Build started
File A is reverted locally to the old version
Build succeeded
Asks for reconcile -> however during reconcile there are no changes to be made
After clicking OK, the File A is checked in with my changes, however my local file is still the old version.
Why does it have this behaviour? This does not seem logical to me. It seems logical until step 8. There it should get the latest version of File A for my local repository. Is this a setting somewhere?
It is my understanding, that Reconcile works by looking at files checked in for the build (shelved, actually), check if the file in your workspace has pending changes, and matches the built version. If they don't match, (ie. you edited in between) it will ask you to merge. If they do match, it will perform an undo, and getting the latest version (which will be the same content, since the TFS server has just checked your changes in).
In other words, if you do not choose to preserve pending changes locally, reconcile won't work and you need to do a get latest manually to get your most recent changes back into your workspace.
Shelving
What happens is that, when you check in, your changes are added to a shelve set. In other words, your changes are shelved. When shelving changes you can choose to roll back your local changes.
For instance when you are working on a problem and suddenly you need to fix another problem with higher priority. Then you can shelve your changes (of the problem you're working on) and roll those changes back locally. This allows you to work on the new problem and check its changes in when you're done. Once finished you can unshelve your previous work (of the first problem) and continue your work.
Gated check-ins
With gated check-ins, shelve sets are created automatically. When shelving you have the option whether your local changes are kept or not. I.o.w. you can shelve changes without rolling them back locally. So when the "Keep local changes" checkbox is not checked you will have this strange behaviour (I also find it very unintuitive).
Locks and 'Preserve local changes' option
The "Preserve local changes" checkbox is disabled however if any of the files in your workspace are locked. Even if they have nothing to do with your changes (also not very intuitive i.m.h.o.). Locks can be put manually on files or automatically in the case of exclusive lockouts (disable "Allow multiple checkouts" checkbox in the projects build configuration). So if you have exclusive lockout and someone modifies a file then it becomes locked and therefore you cannot use the "Preserve local changes" option.
Workaround
To workaround this problem I think you can choose one of several poisons:
Do not use gated checkins
Do not use locking and therefore do not use exclusive lockouts
Do not use colleagues
Learn to wait for the build to finish and always perform Get Latest Version (Reconcile will not do that because it will only do that for files you have modified in the mean time) or make sure that you automatically GLV when editing a file.
Do not use TFS :-)
Hope this helps.
Furthermore, if the gated checkin build failes, shelveset files remains as checked-out by build service account. We found a way to undo checked-out files but reconcile doesn't work becuase "Preserve pending changes locally" is greyed out if "exclusive checkouts" is enabled on team project.

Resources