Showing posts with label tfs power tools extension. Show all posts
Showing posts with label tfs power tools extension. Show all posts

Friday, April 02, 2010

TFS API: Creating recursive TFS areas

The following code has been founded at Shai Raiten's blog:

TFS API Part 9: Get Area/Iteration Programmatically

TFS API Part 11: Get Area/Iteration Security Settings Using IAuthorizationService

He created a fantastic serie how to work with the API!!!
Thanks Shai



Simple Call:
NodeInfo nodeInfo = this.GetAddNode("\\new area name1", "YourProject", StructureType.Area);
NodeInfo nodeInfo = this.GetAddNode("\\new area name2", "YourProject", StructureType.Area);

Recursive Calls:
NodeInfo nodeInfo = this.GetAddNode("\\new area name\\area 1", "YourProject", StructureType.Area);
NodeInfo nodeInfo = this.GetAddNode("\\new area name\\area 2", "YourProject", StructureType.Area);





public enum StructureType
{
Iteration = 0,
Area = 1
}

private NodeInfo GetAddNode(string ElementPath, string projectName, StructureType nodeType)
{
NodeInfo retVal;
string rootNodePath = "\\" + projectName + "\\" + nodeType.ToString();

//Check if this path already exsist
string newPath = rootNodePath + ElementPath;
try
{
retVal = css.GetNodeFromPath(newPath);
if (retVal != null)
{
// return existing node
return retVal;
}
}
catch (Exception ex)
{
if (ex.Message.Contains("The following node does not exist"))
{
//just means that this path is not exist and we can continue.
}
else
{
throw ex;
}
}

int BackSlashIndex = ElementPath.LastIndexOf("\\");
string Newpathname = ElementPath.Substring(BackSlashIndex + 1);
string NewPath = (BackSlashIndex == 0 ? string.Empty : ElementPath.Substring(0, BackSlashIndex));
string PathRoot = rootNodePath + NewPath;
NodeInfo previousPath = null;
try
{
previousPath = css.GetNodeFromPath(PathRoot);
}
catch (Exception ex)
{
// had to update the string from shai's original code
if (ex.Message.Contains("TF200014: The following node does not exist:"))
{
//just means that this path is not exist and we can continue.
previousPath = null;
}
else
{
throw ex;
}
}
if (previousPath == null)
{
//call this method to create the parent paths.
previousPath = GetAddNode(NewPath, projectName, nodeType);
}

string newPathUri = css.CreateNode(Newpathname, previousPath.Uri);
NodeInfo ni = css.GetNode(newPathUri);

Console.WriteLine("Creating Area: " + ni.Path.ToString());
return ni;
}

TFS API: Get Team Project

The following method retrieves the TeamProject over TFS API:

    private TeamProject GetTeamProject()
{
VersionControlServer versionControl = (VersionControlServer)server.GetService(typeof(VersionControlServer));
TeamProject teamProject = versionControl.GetTeamProject("ProjectName");
return teamProject;
}

TFS API: List all TFS Users

The following code lists all TFS users over the API.

[System.Diagnostics.DebuggerStepThrough]
private ICredentials GetCredentials()
{
return new NetworkCredential("user", "pwd", "domain");
}


    public TfsWrapper()
{
server = new TeamFoundationServer("https://your.tfs.com/tfs/store", GetCredentials());
server.Authenticate();
css = (ICommonStructureService)server.GetService(typeof(ICommonStructureService));
gss = (IGroupSecurityService)server.GetService(typeof(IGroupSecurityService));
tfsIdentities = new List<Identity>();
}


public void ReadTfsUsers()
{
TeamProject tp = this.GetTeamProject();
Identity[] appGroups = gss.ListApplicationGroups(tp.ArtifactUri.AbsoluteUri);

foreach (Identity group in appGroups)
{
Identity[] groupMembers = gss.ReadIdentities(SearchFactor.Sid, new string[] { group.Sid }, QueryMembership.Expanded);
foreach (Identity member in groupMembers)
{
Console.WriteLine(member.DisplayName);
if (member.Members != null)
{
foreach (string memberSid in member.Members)
{
Identity memberInfo = gss.ReadIdentity(SearchFactor.Sid, memberSid, QueryMembership.None);

if (memberInfo.Type == IdentityType.WindowsUser)
{
if (!this.tfsIdentities.Contains(memberInfo))
this.tfsIdentities.Add(memberInfo);

// Console.WriteLine(" {0}", memberInfo.DisplayName);
//Console.WriteLine("AccountName :" + memberInfo.AccountName);
//Console.WriteLine("Deleted :" + memberInfo.Deleted);
//Console.WriteLine("Description :" + memberInfo.Description);
//Console.WriteLine("DisplayName :" + memberInfo.DisplayName);
//Console.WriteLine("DistinguishedName :" + memberInfo.DistinguishedName);
//Console.WriteLine("Domain :" + memberInfo.Domain);
//Console.WriteLine("MailAddress :" + memberInfo.MailAddress);
//Console.WriteLine("Sid :" + memberInfo.Sid);
//Console.WriteLine("Type :" + memberInfo.Type.ToString());
//Console.WriteLine("*********************************");
}
}
}
}
}
}

Friday, October 16, 2009

MS Build Shell Extension

MSBuildShellExtension lets you build .NET projects without ever opening Visual Studio or the command prompt. MSBuild targets can be executed from your favourite file system tool like Windows Explorer or Total Commander. The possibility to extend MSBuildShellExtension with your own targets and editors, makes it a very flexible and useful tool for all .NET developers.


Sunday, December 21, 2008

Visual Studio Team System 2008 Team Foundation Server Power Tools Explorer Extensions

I'm not a 100% sure but I think this is getting installed with Visual Studio Team System 2008 Team Foundation Server Power Tools:





Especially I like the comparsion with workspace version :-)

Shared Cache - .Net Caching made easy

All information about Shared Cache is available here: http://www.sharedcache.com/. Its free and easy to use, we provide all sources at codeplex.

Facebook Badge