TFVC API:如何获取文件属性“可执行文件”和“符号链接”

问题描述

在TFVC版本中,我可以控制一些可执行文件和其他符号链接

当您查看UI中的变更集时,我们可以看到该文件具有一个属性

script with executable property

在nuget软件包VersionControl.QueryHistory()中使用TFVC API调用Microsoft.TeamFoundationServer.Client时,我还可以看到与添加文件相对应的更改具有以下属性

file with property from API

我的问题是,使用TFVC Api,我不知道如何获取此更改的属性

我想找到一种方法来知道变更集中包含的“属性”变更类型的类型是什么。尤其是如何知道此“属性”是“可执行”属性还是“符号链接属性

TFVC似乎知道文件是符号链接,因为它显示了一些不同的图标(请注意箭头):

icon of symlink

检索到的对象类型

  • 变更集:Microsoft.TeamFoundation.VersionControl.Client.Changeset
  • 更改:Microsoft.TeamFoundation.VersionControl.Client.Change
  • 文件/项目:Microsoft.TeamFoundation.VersionControl.Client.Item(包含名为AttributesPropertiesPropertyValues的集合,这些集合可能包含数据但为空)

Internet或MSDN文档在这里没有帮助:(

注意:目标是将支持添加git-tfs

解决方法

您可以在Libray TfvcItem中检出Microsoft.VisualStudio.Services.Client类。 TfvcItem对象具有IsSymbolicLink属性,可以确定该项是否为符号链接。

您可以使用TfvcHttpClient对象方法来获取ChangeSet,然后 获取TfvcItem对象。参见以下示例:

 string tfsurl= "http://instance/tfs/DefaultCollection";
 string Project = "project";
 
 NetworkCredential netCred = new NetworkCredential("username",@"password","domain");
            
 Microsoft.VisualStudio.Services.Common.WindowsCredential winCred = new Microsoft.VisualStudio.Services.Common.WindowsCredential(netCred);
     
 VssConnection _connection = new VssConnection(new Uri(tfsurl),winCred);

 TfvcHttpClient tfvcClient = _connection.GetClient<TfvcHttpClient>(); 

 var changesets = tfvcClient.GetChangesetsAsync().Result;
      
 foreach (var changeset in changesets)
 {
       var changesetRes =  tfvcClient.GetChangesetChangesAsync(changeset.ChangesetId).Result;
            
       foreach (var change in changesetRes) 
       {
          var item = (TfvcItem)change.Item;
       }
  }

请参见下面的TfvcItem对象:

enter image description here

,

“ Team Explorer Everywhere”以某种方式创建了一个名为Microsoft.TeamFoundation.VersionControl.Executable的KVP,而我猜测的是ContentMetadata,它显然是NULL-应该在API的哪个位置获取该数据? / p>