您好我正在尝试通过TFS API创建新的工作项,这是我在下面使用的方法,以获取可以分配工作项的有效用户列表.不知何故,它在validUserSids行上给了我一个空引用异常.谁知道这里有什么问题?
private string[] TFSUsers(string server)
{
// Get a Reference to Team Foundation Server.
TeamFoundationServer tfs = tfsdata.GetTFS(server);
// Get a reference to Group Security Service.
IGroupSecurityService gss = (IGroupSecurityService)tfs.GetService(typeof(IGroupSecurityService));
// Resolve to SIDs
Identity validUserSids = gss.ReadIdentity(SearchFactor.AccountName, "TFS Valid Users", QueryMembership.Expanded);
// Resolve to actual users
Identity[] validUsers = gss.ReadIdentities(SearchFactor.Sid, validUserSids.Members, QueryMembership.None);
List<string> Users = new List<string>();
foreach (Identity user in validUsers)
{
Users.Add(user.DisplayName);
}
return Users.ToArray();
}
Run Code Online (Sandbox Code Playgroud) 长话短说.分析后,此命令占用处理的0.1%
var ChangesetList = TFSConnection.GetInstance().GetVersionControl().QueryHistory
(Path, VersionSpec.Latest,0, RecursionType.Full, "", null,
VersionSpec.Latest, Int32.MaxValue,true, false);
Run Code Online (Sandbox Code Playgroud)
这一个,65.7%.(有趣的是,内部的所有处理只消耗3%)
foreach (Changeset changeset in ChangesetList)
Run Code Online (Sandbox Code Playgroud)
我得到我的清单需要几秒钟......发生了什么事?为什么在列表中迭代这么慢?
有没有更快的方法来做到这一点?
编辑:另外,为什么我不能直接将其转换为List<Changeset>?
我可以在TeamProject中查询所有构建,如下所示:
var bServer = teamProjectCollection.GetService<IBuildServer>();
IBuildDetail[] builds = bServer.QueryBuilds("myTeamProject");
Run Code Online (Sandbox Code Playgroud)
这产生builds了给定的所有内容myTeamProject.但我只对昨天的版本感兴趣.
在我得到结果后,我显然可以过滤掉builds.
我仍然想知道是否存在QueryBuilds()在提供的时间跨度内获得构建的过载.
背景:
在我原来的TFS构建解决方案中,自定义代码活动将捕获BuildDetail对我们很重要的属性,并使用Microsoft.Office.Interop.Excel将它们添加到Excel工作表中.
这很方便,因为它发生在Build期间,我们的"BuildLog.xls"始终是最新的.
不幸的是,这导致了这个问题,所以我不得不删除代码活动,我正在实施计划B:计划每天启动一次的控制台应用程序,查询昨天的构建并将它们添加到我的Excel文件中.
我正在使用TFS SDK,我有一个方法,可以获得最新版本的项目.但是当我调用方法时,它总是重新下载文件.这也需要很长时间.
我试过了,我得到了changeSet,我比较了特别的项目.如果项目有更改,请下载它.但这种方式也需要很长时间.
这是我没有检查changeSet的第一个代码
ItemSet items = sourceControl.GetItems(itemPath, VersionSpec.Latest, RecursionType.Full);
foreach (Item item in items.Items)
{
localName = item.ServerItem.ToString();
localName = localName.Substring(2, (localName.Length - 2)).Replace("/", "\\");
switch (item.ItemType)
{
case ItemType.Any:
throw new ArgumentOutOfRangeException("ItemType returned was Any; expected File or Folder.");
case ItemType.File:
item.DownloadFile("D:\\WORK\\Tries\\"+localName);
break;
case ItemType.Folder:
Directory.CreateDirectory("D:\\WORK\\Tries\\"+localName);
break;
}
}
Run Code Online (Sandbox Code Playgroud)
这是我检查变更集的新代码
ItemSet items = sourceControl.GetItems(itemPath, VersionSpec.Latest, RecursionType.Full);
foreach (Item item in items.Items)
{
localName = item.ServerItem.ToString();
localName = localName.Substring(2, (localName.Length - 2)).Replace("/", "\\");
var histories = sourceControl.QueryHistory(itemPath, VersionSpec.Latest, 0, …Run Code Online (Sandbox Code Playgroud) 我想获取特定TeamProject的Web访问页面的URL.
我发现了一些使用TswaClientHyperlinkService对象调用GetHomeUrl(new Uri("MyprojectName"))的示例,但是我无法为此提供正确的Uri值.也许我不明白如何格式化参数..
我知道如何获取webaccess的基本URL,但我想进入特定团队项目集合中特定团队项目的页面.
我正在寻找一个示例或资源链接,以解释如何从外部应用程序向TFS 2012添加新工作项.我已经读过TFS 2012具有允许第三方应用程序与之交互的Web服务.我一直在研究如何添加一个新的工作项,我没有找到任何关于如何做到这一点的例子.
我想以编程方式找出工作区是否包含最新文件.我不想做Workspace.Get(),因为它执行相当于"获取最新".我只是想知道我的工作空间是否需要"获取最新".
我正在Build.I计划中进行此检查有一个像这样的方法:
public static bool HasLatestFiles(Workspace ws)
{
bool hasChanges = false;
/* need correct code to query if ws has latest files */
return hasChanges;
}
Run Code Online (Sandbox Code Playgroud)
什么是正确的代码使用?
我坚持使用TFS API的简单问题,当我获得工作项目时,我无法得到workitem Effort数据,其想法是通过特定标准从TFS获取工作项,然后更改Effort数据并将其保存回TFS.现在我可以获得工作项,并按字段更新任何数据,但我发现如何获得Effort并更新它.

查询从TFS获取数据:
SELECT * FROM WorkItems WHERE [System.WorkItemType] = 'Task' AND [Assigned to] = 'name'
ORDER BY [System.WorkItemType], [System.Id]
Run Code Online (Sandbox Code Playgroud)
这是获取字段的代码
public void getDataFromTfs()
{
Console.WriteLine("Getting data from TFS to Store");
Console.WriteLine("*********************");
setQuery();
Console.WriteLine("Query" + byTasksModified.ToString());
Console.WriteLine("*********************");
Console.ReadLine();
credentials = new System.Net.NetworkCredential("xxxxx", "xxxxxx", "xxxxx");
TfsTeamProjectCollection teamProjectCollection =
new TfsTeamProjectCollection(new Uri(@"LINK HERE"), credentials);
teamProjectCollection.EnsureAuthenticated();
Store = (WorkItemStore) teamProjectCollection.GetService(typeof(WorkItemStore));
WIC = Store.Query(byTasksAssignedTo);
Console.WriteLine("Data fetched into Store");
foreach (WorkItem workItem in WIC)
{
Console.WriteLine("ID: {0}", workItem.Id);
Console.WriteLine("Title: {0}", workItem.Title);
}
}
Run Code Online (Sandbox Code Playgroud)
在这里,我通过特定查询获得所需的所有任务,然后我有方法来提取特定任务 …
我正在尝试使用BuildHttpClient获取集合的构建信息。但它在扔
VssResourceNotFoundException:API 资源位置 {GUIS} 未在http://tfsserver/tfs 上注册
以下代码示例产生错误:
var url = new Uri("http://tfsserver:8080/tfs");
TfsTeamProjectCollection ttpc = new TfsTeamProjectCollection(url);
BuildHttpClient client = ttpc.GetClient<BuildHttpClient>();
List<Build> builds = client.GetBuildsAsync().Result;
Run Code Online (Sandbox Code Playgroud) 我正在尝试在 asp.net core(2.1) mvc 应用程序中使用以下代码连接 Azure DevOps
Uri orgUrl = new Uri("https://dev.azure.com/xxxxx/");
String personalAccessToken = "xxxxx";
VssConnection connection = new VssConnection(orgUrl, new VssBasicCredential(string.Empty, personalAccessToken));
Run Code Online (Sandbox Code Playgroud)
但是得到这个错误 "VssUnauthorizedException: 'VS30063: You are not authorized to access https://dev.azure.com.'"
相同的代码在 .net 核心控制台应用程序中工作,请有人帮助我吗?