Automatically lock a file on checkout (VS2017 w/On Premises TFS) - tfs

My project recently migrated from VSS to TFS, and we are using TFVC for our main CM and documentation repo. In order to simplify things and reduce the system shock, we would like to automatically force a lock of files on check out. Is there a way to do this in a VS 2017 (On-Premises TFS setup)?
I have already tried this, and it doesn't work:
Team->Team Project Collection Settings->Source
Control...->Workspace Settings Tab: Changed default workspace
type from "Local (recommended)" to "Server".
Within Team->Team Project Settings->Source Control...->Check-out Settings Tab: Changed enable multiple check-out to UNchecked.
Lastly, I would like to apply the changes globally...I was hoping this would be a server configuration setting. Is this true, or does every single person on the team have to make local workspace changes?

You can set the default type for new workspaces (Manage project collection workspace settings for your team) but any team member can update the type for own workspace. The option enable multiple check-out is applied to whole repository but using of a local workspace ignores this option (When might I need to use a server workspace?). There is no option to lock the workspace type.

Related

Can multiple checkout be enabled just in one branch in tfs 2013?

We are using TFS2013 and we have need to have main branch on server workspace with disabled multiple checkouts, and to have another branch again on server workspace but with enabled multiple checkouts. Is this possible in any other way than using local workspace on that second branch?
Thanks!
No. The settings for checkout are at a team project level. However, there's no good reason to have exclusive checkouts enabled in the first place -- they are a terrible detriment to productivity. If two developers change the same file, they'll have to merge the files. It's not a big deal.

Visual Studio TFS checkout missing "Check out" checkout type

When my guys checkout a file, I would like them to lock it so others can't also make changes, I see from this post: http://msdn.microsoft.com/en-us/library/jj155783.aspx that this is possible using the Check Out type, however, this appears to be missing from the list of options I have available. I only have Unchanged and Check In.
I am using the free version of TFS in the cloud linked directly with VS2013.
I am using TFS Source Control and have "Enable Multiple Checkouts" disabled. I have also changed the default workspace type to server from local.
This article on MSDN describes the available lock types:
In Visual Studio Team Foundation Server 2012, check-out locks are
generally not effective because of local workspaces (see Decide
between using a local or a server workspace). Specifically, check-out
locks are:
Not enforceable because other users might be using local workspaces.
Not available if you are using a local workspace.
Disabled if a member of the Administrators security group of your
team project collection has enabled asynchronous checkout for your
team’s server workspaces.
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.
Check whether your workspace is a local one or if the administrator has set the option for asynchronous check outs.
In my installation of Visual Studio Online I have a local workspace by default. As soon as I changed it to be stored on the server, the Check Out option was available.
In order to change the type of workspace, carry out the following steps:
In Source Control Explorer, locate the workspace drop down at the top and choose Workspaces....
Select Edit, then Advanced.
Change location from Local to Server.
Exit the dialogs using the Ok or the Close buttons respectively.
Exclusive checkout option will not be available if the workspace Location is set to Local. If that option is needed then workspace location under workspace settings needs to be set to be “Server”.
First open team explorer settings the and go to the settings, click on source control under the Team project Collection.
then uncheck enable asynchronous checkout in server workspaces
now you can disable multi checkout

change check-in setting for entire project

We have a TFS server setup with three projects. Recently we wanted to change TFS so that code checkins had to have a Work Item Number associated with it. I was able to accomplish this by:
In Visual Studio
Team -> Team Project Settings -> Source Control
Then select checkin policy tab and add "Require associated work items."
Source
The problem is that it only seemed to work for one of the three (the first one) projects. I've tried Team -> Team Project Collection Settings but there is no option for the checkin policy.
I've also tried highlighting the individual project I wanted to change the check in policy but they all seem to show that the checkin policy has been setup correctly for requiring a work item with code checkin.
How can I change the settings that all the projects on the TFS server have the same checkin policy?
Check-in policies are set per team project. There is no global meaning collection or server level way of setting and enforcing check-in policies on all of existing and future team projects. You will need to add appropriate check-in policies for each and every team project you need using the project level source control setting in Team Explorer. You can also use TFS client SDK to automate that process to iterate all or some of the existing team projects and add check-in policies. Another option is to take advantage of TFS server side events to get notified when a new team project is created and add check-in policies in response in case of automating the configuration of check-in policies for newly created team projects.
Team Foundation Server Event Service

TFS Server 2012 and Promoting changes

I started using TFS Team explorer 2012 and happen to notice a new process called promoting. As I understand it, the Team Explorer detect any changes made to the files outside of the TFS explorer and count them for promotion? Am I right?
How do I take care of the situation where I made a change to the file which is already checked out through TFS, then made a change via Windows Explorer\Notepad but dont want to include the changes made through the Windows Explorer\Notepad.
This is a new feature of TFS 2012 called Local Workspaces.
You are correct in that changes made outside of visual studio can be included in the check-in by promoting them, if they are not already under source control.
If they are already in source control and you do not want to commit them, then you would need to right click the file and choose Exclude. This will move the file from Included Changes into Excluded Changes.
If you do not like the new Local Workspaces you can tell TFS to go back to the old model of Server Workspaces:
Open Team Explorer
Go to Settings
Under Team Project Collection select Source Control
Click the Workspace Settings Tab
Here you can choose the workspace type.
While everything that discens said is correct, one thing bears explicit mention: there is no change to the level of granularity of Team Foundation Server. You still check out files and edit files and check-in files.
In your example, if you have a file checked out and you edit it in Notepad, the changes will be checked in. There is no change here from previous behaviors. There is no way to keep these changes from being checked in, short of saving the file with a different file name.

TFS file must remain locked

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

Resources