I tried to remove a GLOBALLIST from GLOBALLIST xml data and then tried to import the updated xml data to tfs server but nothing get updated using below line of code.[ no error is throwing ]
store.ImportGlobalLists(collectionGlobalListRoot.InnerXml);
Note: here store is WorkItemStore
and collectionGlobalListRoot
is the XMLDocument
contains entire updated globallist xml of collection.
Addition of GlobalList is working fine here.
I am wondering do i have to use any different mechanism to destroy a globallist via API?
Any help would be highly appreciated.
Usually the normal flow of modify Global list is export the Global List XML, modify the XML and import it back.
However, deleting a Global List is not possible. Because the Import/Export methods are set up in a way that you can also add or update 1 list instead of everything, you can never delete a list. If you don't send the XML of the particular list, it is not updated.
For deleting/destroying the Global list you need to create a special XML package that you can send to the SendUpdatePackge method of the WorkItemStore object. Sample code as below:
string globalListName = "Test Global List";
XmlElement returnElement;
XmlDocument root = new XmlDocument();
//Create a package element
XmlElement newChild = root.CreateElement("Package");
root.AppendChild(newChild);
//Create a Destroy Global List element
XmlElement element2 = root.CreateElement("DestroyGlobalList");
element2.SetAttribute("ListName", "*" + globalListName);
element2.SetAttribute("ForceDelete", true.ToString(CultureInfo.InvariantCulture));
newChild.AppendChild(element2);
//Send Update to Work Item Store
store.SendUpdatePackage(newChild, out returnElement, false);
More details please refer this blog: Deleting (or destroying) a Global List with the TFS API
You can use InternalAdmin.DestroyGlobalList()
method to delete global list.
public static void DestroyGlobalList(Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore store, string globalListName, bool force)
Member of Microsoft.TeamFoundation.WorkItemTracking.Client.InternalAdmin
Summary: Destroys the passed in Global list.
Parameters: store: force: Destroy the lists even if they are in use. globalListNames:
Code for your reference:
using System;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string url = "http://xxx:8080/tfs/CollectionName/";
string GlobalListName = "ListName";
TfsTeamProjectCollection ttpc = new TfsTeamProjectCollection(new Uri(url));
WorkItemStore wis = ttpc.GetService<WorkItemStore>();
InternalAdmin.DestroyGlobalList(wis, GlobalListName, false);
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.