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?
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.
UPDATE:
Please refer to this article to check How Does Check-in Policy Work? :
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