Frage

I am creating a check-in policy using:

using Microsoft.TeamFoundation.VersionControl.Client;

I want to get the current TFS Team Project Name from the current workspace or the PendingCheckin

Any ideas?

War es hilfreich?

Lösung

You can use VersionControlServer.GetTeamProjectForServerPath on a pending change thus:

var pendingChange = pendingCheckin.GetAllPendingChanges().FirstOrDefault();
if(pendingChange != null) {
    return vcs.GetTeamProjectForServerPath(pendingChange.ServerItem);
}

This also means you can detect if pending changes span multiple team projects.


Edit/expansion:

Now that I think about it, you should probably use the local path, since the files you're checking in might not be on the server yet (adds).

So you can use Workspace.GetTeamProjectForLocalPath instead:

var workspace = pendingCheckin.GetWorkspace();
var pendingChange = pendingCheckin.GetAllPendingChanges().FirstOrDefault();
if(pendingChange != null) {
    return workspace.GetTeamProjectForLocalPath(pendingChange.LocalItem);
}

Andere Tipps

You can access it with

  BuildDetail.TeamProject

Find the assembly in: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.Build.Client.dll

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top