TFS file must remain locked - tfs

I have some 3rd party dlls checked into TFS
Our machines were renamed and now TFS believes they are checked out for edit by me on another machine.
I tried tf lock /lock:none contrib64/* /workspace:oldmachine;myusername but I get the error
TF10152: The item $/XXX/YYYY/contrib64/third_party.dll must remain
locked because its file type prevents multiple check-outs.
1, Is there any way around this ?
2, Is TFS really this bad or is it just me ?
3, Is the purpose of TFS to make us nostalgic for VSS?
ps It's a hosted version so I can't just get the admin to fix it.

Undoing the lock won't work on those files because they are binary, as binaries cannot be merged they must be locked if they are checked out.
As the machine the workspace resides on no longer exists (the machine has been renamed) the best thing to do is delete the workspace.
from a Visual Studio command prompt
tf workspace /delete oldmachine;myusername /collection:http://*tfsserver*:8080/tfs/*collection*
This will remove the workspace and undo all pending changes

If you don't want to delete the workspace, you can undo the change and unlock the file after that:
Using a Visual Studio developer command prompt:
tf undo "$/<server-path-to-file/folder>" /workspace:"<workspace>;<user>" /collection:<collection-url> /recursive
tf lock "$/<server-path-to-file/folder>" /lock:none /workspace:"<workspace>;<user>" /collection:<collection-url> /recursive

Files with .dll extension as well as other extensions like .exe, .doc, .docx, etc. are automatically locked because (as mentioned) here they cannot be merged.
If you want to disable the automatic lock and allow these files to go through gated check-in, follow the steps below:
Log in to your build server.
Open visual studio.
In team explorer, log into your team project.
Go to "Settings".
Under "Team Project Collection", select "Source Control".
Set "File Merging" property to "Disabled" for any file extension you don't want to be automatically locked.
Reference: https://blogs.msdn.microsoft.com/phkelley/2008/11/12/everything-you-ever-wanted-to-know-about-locks/
This worked for me.

I needed to change settings in 2 places:
At Visual Studio, team project window, Settings->Team Project Collection -> Source Control
Enable File Merging for the extension.
2) At Visual Studio, team project window, Settings->Team Project -> Source Control
Enable the multiple check-out box

Related

TFS not tracking changes if items added manually and not included into vs2015 solution

I've added a folder with asp.net core project which isn't supported by Visual Studio 2015 (which is used for everything else) and thus not included to the general solution.
To have those files in source control I had to manually add them using "add items to folder" command in source explorer. So they are checked-in but tfs not tracking changes for them anymore although there are differences that are shown if compare to the latest folder on the server:
How do I make TFS track them and show pending changes for edited files?
According to your description, looks like these files are all out side of Visual Studio.
Not sure if you are using server workspace or local workspace.
When adding or editing the workspace you click Advanced >> . There is a setting of Location: Local/Server.
For local workspace, when your script or anything else changes files outside Visual Studio, your workspace detects the changes automatically.
It also detects adds or deletes but you have to include them to your Pending Changes manually with the link under Excluded Changes.
For server workspace, you could choose to use Reconcile command. See https://stackoverflow.com/a/22860674/932282 for a complete answer.
Besides, you could also take a look at other solutions in below similar question:
How to have TFS 2010 detect changes done to files outside of Visual Studio?
Force TFS to detect changes
I think you just added them to source explorer and not to the solution, as you said. In this case, there is no editor application (even your VS) that is responsible for doing the check-out operation because they are not aware of TFS. On the other side, TFS can detect that changes have happened to the files but can not track them.
If you do not activate the "Get the latest version before check-out" option in your team project, then you can go to the source control and check-out those files manually and then check-in them manually again when your work with them is done.
Please before doing this, take a backup of your source code for caution.

TFVC pending changes without checkout in TFS Everywhere

Using TFS everywhere. Editing files without "checkout for edit".
after it, unable to see edited files list in "TFVC pending changes" window.
Try to see if your project is Offline, that is the behavior when your project is not connected with the TFS.
1- Right-click on the solution name right at the top of the Solution Explorer and select the Go Online option
2- If that doens't help, please check your connections to the tfs through the Team Menu -> Manage Connections.
3- If still happens, try to restart the Visual Studio
You are using Team explorer everywhere. Try to check whether your project is offline:
Right click your project > Team > Return Online.
BTW, the project will be offline if you switch workspace to other that isn’t include that project.
Update:
Pending changes window > Click Actions > Detect Local Changes, then the modified file (tracked by source control) in current workspace will be included in Included Changes

Complete nuke all changes in visual studio and reset from TFS

I am using Visual Studio 2013. Regarding TFS workflow, there are issues I have when working on a bug or work item, after I am finished, I move the changes into a shelfset for further review, undo my changes by right clicking on the pending changes and clicking undo. The move on to the next issue or enhancement. The shelfsets can be indpendendly reviewed and then applied to whatever branch they are currently needed.
The problem I have is that undoing through visual studio does not completely reset the solution to a completely clean state. There are often orphaned files around or projects that have references to non-existing files or other such problems. I'd like to be able to completely nuke and reset my solutions from source control as if I am a new developer and I have not found an easy solution to do this.
Currently, the only way I can accomplish this is to go to "Source Control Explorer" remove the file system mapping for the project. Go to the file system, removed the folder. Go back into "Source Control Explorer" add the mappings back in. And then "Get Latest Version".
Is there an easy way to completely reset a solution in Visual Studio with TFS?
You can achieve this in Visual Studio 2010 without Power Tools. Process is likely similar for other VS versions.
Open the Source Control Explorer. Right-click the entry you want to reset, then choose "Get Specific Version." Select the version you want to reset to. Ensure that the two checkboxes are checked:
☑ Overwrite writeable files that are not checked out
☑ Overwrite all files even if the local version matches the specified version
This will overwrite all locally mapped files with the server's version. (And will correspondingly take time proportionate to the number of files.) I do not believe that this operation will remove any unmapped files.
If you have the Power Tools installed, call tfpt scorch /deletes /recursive /diff. That should make your local folder match the server exactly.
You can also call tfpt treeclean, which will just delete any item that is not mapped to TFS. It won't update or replace any changed files though, like scorch will.

TFS Power Tools 2010 Showing File Checked Out

Somehow TFS Power Tools thinks my file is checked out, it won't let me check-out because that option is greyed out.
When I look in windows explorer I see my file with the little pen icon overlay. When I right-click and go to "Team Foundation Server", I choose undo but then get the message "There are no changes to undo in the selection or any children of the selection". If I right-click and go to Check-In then I get the message "no pending changes".
When I open source control explorer in Visual Studio it shows no pending changes for the file.
Can anyone please advise any steps I can take to resolve?
Can it be that the file is checked out by you on another workspace? Go to VStudio & check "Team Members" under Team Explorer. Right-click on yourself & select "Show pending changes". This should show all your checked out items, across all workspaces/worstations. You can also undo it there.Eventually, in order to find out what is happening with your file go in VS to"File">"Source Control">"Find in Source Control">"Status"Select the path to your module & hit 'find'. This should reveal if any other person has this file checked out
Seems strange, lets check common scenarios:
File is actually not checked-out but shown as checked-out in explorer
=> Please try to checkout file through VS, if you can, there is definitely some problem in Power Tools integration to Source COntrol. Restart machine. If problem is same then it might be case TFS credentials are different from Login windows credentials, status don't update sometimes.
File has set property of single check out by Admin & checked- out by anyone else thus preventing you from either check-out or check-in also undo checkout is not possible for same reason.
Create new workspace or try on other machine with different workspace.
=> Some times workspace conflicts, multiple mapping of same directory through multiple workspace creates problems.
Power Tools installation is corrupted or incompatible with some other extension.
=> Many a times, frequent abrupt power-off or etc corrupts software, reinstall latest Power tools. If problem persists, check if some other extension for VS or windows shell is not interrupting functioning.
Hope that helps, if not, let me know with more details like installed extensions, power tools version/ update installed.

How to undo changes in tfs coming from unmanaged workspace?

I have a workspace that is lost forever. I have some files checked out from this workspace. I want to unlock them but I can't. I tried to do:
TF UNDO $/MyProject/MyFolder/MyFile.cs /WORKSPACE:LOST;user /s:http://mysite:8080
But I got this message:
The workspace LOST;user is not on this
computer. Run get (get all if edits
were undone) on the computer hosting
that workspace to update it with the
change s that have been made on the
server.
Does exist any way to undo a file (not every file) checked out by unavailable workspace?
If the workspace is lost, then I would just delete it. Deleting it undoes any changes that were made in it.
tf workspace /delete WorkspaceName;WorkspaceOwner
As long as you have the appropiate permissions I would think that the method from this answer by #BubbleSort should work: https://stackoverflow.com/a/17870318/1982894
He used TFS 2012, I have tested it in TFS 2010 and it works there too.
Answer copied for easy reference:
(Note: I have the TFS Power Tools installed so if you don't see the
described options you may need to install them.
http://visualstudiogallery.msdn.microsoft.com/b1ef7eb2-e084-4cb8-9bc7-06c3bad9148f
)
If you are accessing the Source Control Explorer as a team project
administrator (or at least someone with the "Undo other users'
changes" access right) you can do the following in Visual Studio 2012
to clear a lock and checkout.
From the Source Control Explorer find the folder containing the locked file(s).
Right-click and select Find then Find by Status...
The "Find in Source Control" window appears
Click the Find button
A "Find in Source Control" tab should appear showing the file(s) that are checked out
Right click the file you want to unlock
Select Undo... from the context menu
A confirmation dialog appears. Click the Yes button.
The file should disappear from the "Find in Source Control" window.
The file is now unlocked.

Resources