Yerel olarak ya da kodla eşlenmemiş proje olduğunu öğrenmem gerekiyor. foreach
'u workItemStore = new WorkItemStore(projects)
için yapabildiğimden ve IsMapped
veya MappingPath
gibi herhangi bir proje bilgisi alabildiğimden Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory.GetTeamProjectCollection()
kullanarak tüm TFS projelerini alabilirim.Program, TFS'de projelendirilmiş olarak nasıl kontrol edilir?
Bilgi Gerekli olan Visual Studio'daki Team Explorer'ın Kaynak Denetim Gezgini'nden kolayca erişilebiliyor, ancak bunu C# kodundan yapmam gerekiyor. Denedim budur
:
var projects = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(_tfsServerUri));
projects.Authenticate();
var workItemStore = new WorkItemStore(projects);
foreach (Project pr in workItemStore.Projects)
{
pr.IsLocal;
}
UPD: CEVAP
Miker cevabı iyidir, ama bir kusuru vardır eklemek istiyorum. Kök dizininiz eşlendiyse ancak yerel bilgisayarınızda bu kök dizinden tüm projeleriniz yoksa, Miker'in çözümü tüm projelerini geri döndürecektir.
TfsTeamProjectCollection teamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(_tfsServerUri));
teamProjectCollection.Authenticate();
VersionControlServer versionControl = teamProjectCollection.GetService<VersionControlServer>();
string computerName = Environment.MachineName;
WindowsIdentity windowsIdentity = WindowsIdentity.GetCurrent();
// get yours local workspaces
Workspace[] workspaces = versionControl.QueryWorkspaces(null, windowsIdentity.Name, computerName);
foreach (Project pr in workItemStore.Projects)
{
var mapped = false;
foreach (Workspace workspace in workspaces)
{
var path = workspace.TryGetLocalItemForServerItem("$/" + pr.Name);
if (!String.IsNullOrEmpty(path) && Directory.Exists(path))
{
mapped = true;
}
}
// do what you want with mapped project
}