I have Azure DevOps Server v2019.Update1.1 and I want use tfssecurity
cli to create new groups in the project (because graph api is not available for on-premise yet)
To do so I need scope
parameter which will identify project. From documentation: "Specifies the URI of the project for which you want to display groups. To obtain the URI for a project, open Team Explorer, right-click the project, click Properties, and copy the entire entry for URL"
From google results it looks like "vstfs:///Classification/TeamProject/6868ab48-73f8-499d-b4c5-bb743f68ad87"
Is there a way to get that value programatically via cli or api?
Scope is the URI of the project, whose format is vstfs://Classification/TeamProject/00000000-0000-0000-0000-000000000000
. 00000000-0000-0000-0000-000000000000
is the id of the project. You can get the project id from Projects - List REST api:
GET https://{instance}/{collection}/_apis/projects?api-version=5.0
Or you can use the following code to retrieve the URI:
using System;
using Microsoft.TeamFoundation.Server;
using Microsoft.TeamFoundation.Client;
using Microsoft.VisualStudio.Services.Common;
using Microsoft.VisualStudio.Services.Client;
namespace GetTeamProject
{
class Program
{
static void Main(string[] args)
{
VssCredentials cred = new VssClientCredentials();
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri("http://TFS2019:8080/tfs/DefaultCollection"), cred);
tpc.EnsureAuthenticated();
ICommonStructureService css = tpc.GetService<ICommonStructureService>();
ProjectInfo[] projects = css.ListProjects();
foreach (ProjectInfo pro in projects)
{
Console.WriteLine(pro.Name);
Console.WriteLine(pro.Uri);
}
}
}
}