Doniyor Niazov
Doniyor Niazov

Reputation: 1431

TFS 2017: Check in policy is working on check out

I have a custom TFS checkin policy that is used for some of the project in the company. Some of the projects are huge and running the policy for them takes about 10 seconds or so. It is OK to spend 10 seconds every time when someone checks in, because it is going to prevent from problems being created that may take hours. So policy really helps. The issue I am having is, VS is firing the policy not just for checkins, it is firing it from checkouts and saving the checked out file. That is really annoying for everyone. And now I see that developers are disabling the policy to avoid VS freezing.

Anyone knows why would Visual Studio run the policy during the checkout and save?

I don't think VS has any settings that could prevent from running other than checkin, but is there are way in code that I can identify whether the action is Checkin, checkout or save so that I could write my logic accordingly?

Upvotes: 2

Views: 1538

Answers (1)

Andy Li-MSFT
Andy Li-MSFT

Reputation: 30372

Generally Check-in policy only works when check in pending changes. So please double check if the issue is really caused by the custom check-in policy.

For the check-in policy, you can disable it when check out files to edit, then enable it when you want to check in the pending changes.

To enable a check-in policy

  1. On the Team menu, click Team Project Settings, and then click Source Control.
  2. In the Source Control Settings dialog box, click the Check-in Policy tab.
  3. In the policy type list, select the policy type you want to enable, and click Enable.
  4. Click OK.

To disable a check-in policy

  1. On the Team menu, click Team Project Settings, and then click Source Control.
  2. In the Source Control Settings dialog box, click the Check-in Policy tab.
  3. In the policy type list, select the policy type you want to delete, and click Disable.
  4. Click OK.

See Enable and Disable Check-In Policies for details.


UPDATE:

Please refer to this article to check How Does Check-in Policy Work? :

Before you check-in, TFS evaluates pending changes in your working directory.

So it will spend time on evaluating the pending changes, it's the expected behavior.

No any other settings in VS for custom policy except the ones mentioned in this this link: https://learn.microsoft.com/en-us/vsts/tfvc/set-enforce-quality-gates?view=tfs-2017#in-this-section

Upvotes: 1

Related Questions