是否可以使用Microsoft.TeamFoundation.SourceControl.WebApi回滚变更集?

时间:2019-06-10 19:21:00

标签: azure-devops tfvc

以下代码尝试使用Microsoft.TeamFoundation.SourceControl.WebApi回滚更改集。但是“ 不支持指定的更改类型回滚。”调用CreateChangesetAsync时引发。这是Microsoft.TeamFoundation.SourceControl.WebApi的限制吗?还是我做错了什么?

using System;
using System.Collections.Generic;
using Microsoft.TeamFoundation.SourceControl.WebApi;
using Microsoft.VisualStudio.Services.Client;
using Microsoft.VisualStudio.Services.Common;
using Microsoft.VisualStudio.Services.WebApi;

namespace RestRollBackInTFS
{
    class Program
    {
        static void Main(string[] args)
        {
            const String collectionUri = @"https://myTfs.visualstudio.com/";
            VssConnection connection = new VssConnection(new Uri(collectionUri),
                new VssClientCredentials()
            );
            TfvcHttpClient tfsClient = connection.GetClient<TfvcHttpClient>();
            int changeSetIdToRollBack = 11651;
            var changeSet = tfsClient.GetChangesetAsync(changeSetIdToRollBack, maxChangeCount: 10, includeDetails: true).Result;
            foreach (var c in changeSet.Changes)
            {
                c.ChangeType = VersionControlChangeType.Rollback;
            }
            TfvcChangeset newC = new TfvcChangeset();
            newC.Changes = new List<TfvcChange>(changeSet.Changes);
            var ret = tfsClient.CreateChangesetAsync(newC).Result;
        }
    }
}

0 个答案:

没有答案