How do you prevent two persons from editing the same file? - tfs

In TFS 2010, How do you prevent two persons from editing the same file?

You want to remove the multiple checkout option.
You will need permissions on the Team Project to change it – if you are unsure, speak to your TFS Administrator.
To get to the option itself, first go into Visual Studio, to the Team Explorer and then right click on the project you want to change the option for. Then select Team Project Settings, then select Source Control.
In the dialog that appears, untick “Enable multiple check-out” and hit ok.
(quoted from http://www.neillans.co.uk/?p=492)

If you want to do it on a specific file/check-out, when you choose to Check Out a file the dialog allows you to select from a handful of lock types that can prevent other developers from checking out or in that file while you have it checked out.

In Visual Studio 2015 and 2017 follow the steps:
1. Open Team Explorer if VS and go to Settings
Open Team Project Source Control Settings and uncheck Enable multiple check-out

Related

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

Why are all files write protected and how can I check-in?

I currently work with a Team Foundation Server and Visual Studio. Since two days, I keep getting error messages that I can't write to files (it seems not to matter which file I try to access). I am the only one in my team who has those problems.
So when I try to check-in, I get:
When I click on Overwrite, I can overwrite it. But when I try to check-in pending changes, I don't see any changes. If I modify a source file, I can compare it to the latest version and see that there are changes.
How can I fix this? I simply would like to work ...
Work-around: If I "Check Out for Edit..." the file (so I get the lock) I can edit it. But this doesn't work for the solution file, because somebody else checked it out.
Go to Solution Explorer
Right click on your solution
Click Go online
It seems that your solution is not connected to the Team Foundation Server.
I would recommened that you remove the mapping of your workspace, delete all local files of the workspace and then get a fresh version (Get latest version) from the Team Foundation Server.
To remove mapping you need to open the Source Control Explorer in Visual Studio. Navigate to the Branch you are working on and open the Context Menu (right click on branch). In the menu you select Advanced->Remove mappings....
In the dialog you can edit or remove the mapping of your workspace. (Note: When you select Remove mapping then will all files in the Local Folder be removed that are controlled by TFS)
What you also can do is to check the state of your workspace/solution if it is connected to TFS. To do that you need to open the solution in Visual Studio and then open File->SourceControl->Advanced->Change Source Control... in the File Menu of Visual Studio.
In the Dialog you will see if your Solution and projects are connected to TFS and the server they are connected to
You should have the correspondings local files like in the source control.
Go to the local file, right click on it and choose Properties,
in the opened dialog uncheck the read-only checkbox, click Yes to the question if you want to apply changes to all subfolders and files.
Hope this is helpful.
You will face the same problem when setting your Workspace location to server (which in my case happened somehow magically).
To change the location to local again open the source control explorer and in the upper part you find a drop down labeled "Workspace". From this drop down choose "Workspaces...". This opens the "Manage Workspaces" dialog where you can select your workspace and click the "Edit" button. In the Edit dialog click the "Advanced" button and you'll see a drop down for Location where you can change it to Local again.
MSDN provides detailed information on the pros and cons of local and server workspaces.

TFS 2010 - How to make all work items inaccessible for a specific TFS project

I am trying to figure out how to modify the work items permissions on a specific TFS project to inaccessible?
I want to make the work items 'invisible' to all users.
The MSDN documentation is a little unclear (at least for a newbie):
http://msdn.microsoft.com/en-us/library/ms252587.aspx
it mentions TFSSecurity could be used from command line and I think i need to deny WORK_ITEM_READ for that project - could someone provide the syntax for that?
Thanks!!!
You can do it with TFSSecurity. But unless you enjoy command line pain, just use Team Explorer (via Visual Studio).
Right click on a project in Team Explorer and select "Team Project Settings" then select "Areas and Iterations".
In the resulting dialog make sure that the root Area (called "Area") is selected then select the "Security" button in the bottom of the dialog box (next to close).
That will launch the security options for the work items under that Area. From there you can uncheck "View work items in this node" for everyone in the list.
However you will be unable to remove Collection admin's rights to view the work items. You may be able to do that via TFSSecurity.exe but it would be abnormal to do so.

TFS: Choose which Team Project to add a solution too

I have a solution which I developed in VS2008 and which I am trying to add to Source Control (TFS 2010, though the issue happened in TFS 2008 as well). I have several TFS workspaces on my computer and I have access to several Team Projects.
When I right click the solution in my Solution Explorer and choose the "Add Solution to Source Control" option I am never given an option of choosing which Workspace or which Team Project to add the existing solution to. VS2008 then proceeds to add it to the same team project every time. I have tried selecting an alternate workspace/team project in every window where I can see an option for it but it always adds it back to the same one. I even tried changing the name of my new workspace so that alphabetically it was the first thinking that it might be somehow related to that; no luck.
I then tried going to the Change Source Control window where you can add/remove bindings on a solution/project but that window also defaults to the same Team Project as trying to add the solution directly does.
In my experience, the add to source control mechanism tries to use the physical path of the solution to determine which TFS project it belongs to. You could try to move the solution by right-clicking on the solution folder in the Source Control Explorer and choosing "move" to move it to the TFS project of your choice.

How to undo another user's checkout in TFS via the GUI?

As the resident TFS admin, on occasion I am asked to undo a checkout (usually a lock) that a user has on a certain file. This can be done via the command line using the TF.exe utility's Undo command (see http://msdn.microsoft.com/en-us/library/c72skhw4.aspx), but that's kind of a pain.
Is there a way to undo another user's checkout via the GUI?
Out of the box, no, but there are at least a couple of options via add-ons.
TFS Power Tools
TFS Power Tools (Visual Studio 2010)
TFS Power Tools (Visual Studio 2012)
TFS Power Tools (Visual Studio 2013)
TFS Power Tools (Visual Studio 2015)
Once installed:
Open Source Control Explorer
Right-click the item on which checkout is to be undone (or a parent folder of multiple files to be undone)
Select Find in Source Control and then Status
In the Find in Source Control dialog, leave the Status checkbox marked
Optionally, enter a value for the Wildcard textbox
Optionally, enter a username in the "Display files checked out to:" textbox and select that radio button
Click Find
This will result in a list of files
Select the items to undo
Right-click and select Undo
Click Yes when prompted with "Undo all selected changes?"
Team Foundation Sidekicks
Another option is to use the Team Foundation Sidekicks application, which can be obtained here: http://www.attrice.info/cm/tfs/
It has a Status sidekick that allows you to query for checked out work items. Once a work item is selected, there are "Undo pending change" and "Undo lock" buttons that can be used.
Rights
Keep in mind that you will need the appropriate rights. The permissions are called "Undo other users' changes" and "Unlock other users' changes". These permissions can be viewed by:
Right-clicking the desired project, folder, or file in Source Control Explorer
Select Properties
Select the Security tab
Select the appropriate user or group in the Users and Groups section at the top
View the "Permissions for [user/group]:" section at the bottom
I just had this problem myself and found an easier way to clean up old workspaces.
1) In visual studio, open source control explorer.
2) From the 'Workspace' dropdown select 'Workspaces...'
3) A dialog will appear showing the workspaces on your current PC. Select 'Show remote workspaces'
4) You will now also see workspaces from your previous PC (as long as they are from the same user account). Select the old workspace(s) and click 'Remove'. This should delete the old workspace from from TFS along with any persisting checkouts.
I'm sure Arne has found a solution but I hope this helps others who google the issue.
Command line
tf undo /workspace: OtherUserWorkspace;OtherUser $/TeamProject/MyFile.cs /s:http://YourTFSServer:8080
https://msdn.microsoft.com/en-us/library/cc470668.aspx
if you use the tfs power tools undo procedure above you need to do a get or get latest to update your screen. Otherwise it looks like undo has not worked.
The operation completed successfully. Because the workspace Workspace;domain\userID is not on this computer, you must perform a separate get operation in that workspace to update it with the changes that have been made on the server.

Resources