Wednesday 5 August 2020
Read TFS Project name from TFS Project collection using c#
Using Team foundation api.
References:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.dll
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.Client.dll
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.Common.dll
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.WorkItemTracking.Client.dll
Code:
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Server;
using System;
using System.Linq;
class Program
{ private static ICommonStructureService _commonStructureService;
static void Main(string[] args)
{
ReadProject("https://tfssite.com/tfs/UK_ProjectCollection");
ReadProject("https://tfssite.com/tfs/IN_ProjectCollection");
Console.ReadKey();
} public static void ReadProject(String URL)
{
writeFile("Project Collection: " + URL);
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri(URL));
var collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tpc.Uri);
_commonStructureService = collection.GetService<ICommonStructureService>(); var projects = _commonStructureService.ListAllProjects().OrderBy(a => a.Name);
foreach (var project in projects)
{
writeFile(project.Name);
} writeFile("------------------------------------------------------------------------------");
} public static void writeFile(String message) {
using (System.IO.StreamWriter file =
new System.IO.StreamWriter(@"C:\temp\tfs.txt", true))
{
file.WriteLine(message);
}
}
}
Output is the list of project names in tfs.txt file.
Subscribe to:
Post Comments (Atom)
Generate SQL script from entity framework using powershell/visual studio
to run the below command , start PowerShell in visual studio. Select the database project. In PowerShell: Script-Migration this command wi...
-
This solution Works for TFS 2010+ . Open Visual studio Command prompt and run the following script. tf workspace /delete /server:[Site:Port/...
-
for example, the login name is 'mysqluserlogin' 1) Enable the disabled login: ALTER LOGIN mysqluserlogin ENABLE ; 2) Change the lo...
-
By default, Android studio can not connect to the Azure devops source codes. To connect to the Azure devops, a plugins by Microsoft needs t...
No comments:
Post a Comment