Hello Daniel,
The reason you are unable to save new policies and keep getting the warning is that Azure DevOps blocks any configuration saves when it detects a mix of obsolete and new policies. Because the obsolete policies are hidden from the current Visual Studio UI and cannot be deleted from there, your project is essentially stuck in a state where the legacy policies block any check-ins and edits.
As you noticed, the REST API (/_apis/policy/configurations) is strictly for Git branch policies, and tf.exe does not have an active policy management command to solve this.
To clear these hidden obsolete policies, you will need to run a small C# application using the legacy TFVC client API. Once they are cleared, the Check-in Policies tab will properly register new built-in policies without warnings.
Here are the exact steps and code to remove the deprecated policy metadata:
- Create a new C# Console App (.NET Framework 4.8) in Visual Studio. (Note: Do not use .NET Core / .NET 5+ as the legacy client Object Model requires .NET Framework).
- Install the following NuGet package:
Microsoft.TeamFoundationServer.ExtendedClient(v19.x or latest). - Use the following code in your
Program.cs. Replace{UrlToYourCollection}(e.g.,https://dev.azure.com/yourorg) and{YourProjectName}with your specific details:using System; using Microsoft.TeamFoundation.Client; using Microsoft.TeamFoundation.VersionControl.Client; namespace ClearTFVCPolicies { class Program { static void Main(string[] args) { var collectionUri = "{UrlToYourCollection}"; var currentProjectName = "{YourProjectName}"; using (TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri(collectionUri))) { // Authenticate and get the Version Control Server var versionControlServer = tpc.GetService<VersionControlServer>(); // Get the specific Team Project TeamProject teamProject = versionControlServer.GetTeamProject(currentProjectName); // Clear the obsolete policies by setting them to null teamProject.SetCheckinPolicies(null); Console.WriteLine("Obsolete check-in policies have been successfully cleared."); Console.ReadLine(); } } } }
Note: You must be a Project Administrator to successfully run this script.
Once you run this code, restart Visual Studio, go back into Team Explorer -> Settings -> Source Control -> Check-in Policy, and you will now be able to add the updated policies without receiving the warning.
Reference: TFVC check-in policy migrate guide - Remove existing obsolete policies
Note: This response is drafted with the help of AI systems.